From 16634a6d2c269842a831237c98e17da8514e548c Mon Sep 17 00:00:00 2001 From: "seonkyu.kim" Date: Wed, 24 Jul 2024 02:11:28 +0000 Subject: [PATCH] =?UTF-8?q?=20[=E2=9C=A8]=20init=20Project=20Front?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100755 index 0000000..46da398 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,49 @@ +pipeline { + agent any + + environment { + DOCKER_CONTAINER_NAME = 'jjungtable-node' + APP_VOLUME_FRONT = '/home/node/front' // stein-node 컨테이너 내부 경로 + } + + stages { + stage('Clone Repository') { + steps { + git url: 'https://git.ipstein.myds.me/JJUNGTABLE_PJT/Front.git', branch: 'main' + } + } + + stage('Deploy') { + steps { + script { + // Docker 컨테이너 ID 가져오기 + def containerId = sh(script: "docker ps -qf 'name=${DOCKER_CONTAINER_NAME}'", returnStdout: true).trim() + if (containerId) { + // 컨테이너 내부로 파일 복사 + sh "docker cp ${WORKSPACE}/. ${containerId}:${APP_VOLUME_FRONT}" + // 컨테이너 재시작 + // sh "docker restart ${containerId}" + } else { + error "Docker container ${DOCKER_CONTAINER_NAME} not found" + } + } + } + } + } + + post { + always { + script { + def containerId = sh(script: "docker ps -qf 'name=${DOCKER_CONTAINER_NAME}'", returnStdout: true).trim() + if (containerId) { + sh "docker logs ${containerId}" + } else { + echo "Docker container ${DOCKER_CONTAINER_NAME} not found" + } + } + } + failure { + echo "Build failed. Check the console output for details." + } + } +} \ No newline at end of file