49 lines
1.6 KiB
Groovy
Executable File
49 lines
1.6 KiB
Groovy
Executable File
pipeline {
|
|
agent any
|
|
|
|
environment {
|
|
DOCKER_CONTAINER_NAME = 'jjungtable-node'
|
|
APP_VOLUME_FRONT = '/home/node/app' // stein-node 컨테이너 내부 경로
|
|
}
|
|
|
|
stages {
|
|
stage('Clone Repository') {
|
|
steps {
|
|
git url: 'https://git.ipstein.myds.me/JJUNGTABLE_PJT/Back.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."
|
|
}
|
|
}
|
|
} |