[📝] Jenkinsfile 수정
This commit is contained in:
parent
8704d15ccb
commit
9ee719503c
60
Jenkinsfile
vendored
Normal file
60
Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
environment {
|
||||||
|
DOCKER_RELEASE_CONTAINER = 'acamate-back-build-release'
|
||||||
|
DOCKER_DEBUG_CONTAINER = 'acamate-back-build-debug'
|
||||||
|
|
||||||
|
DOCKER_RELEASE_RUN_CONTAINER = 'acamate-run-release'
|
||||||
|
DOCKER_DEBUG_RUN_CONTAINER = 'acamate-run-debug'
|
||||||
|
|
||||||
|
APP_VOLUME = '/src'
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Clone Repository') {
|
||||||
|
steps {
|
||||||
|
git url: 'https://git.ipstein.myds.me/AcaMate/AcaMate_Web.git', branch: env.GIT_BRANCH
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Deploy') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
if (env.GIT_BRANCH == 'main') {
|
||||||
|
// main 브랜치용 작업
|
||||||
|
def containerId = sh(script: "docker ps -qf 'name=${DOCKER_RELEASE_RUN_CONTAINER}'", returnStdout: true).trim()
|
||||||
|
if (containerId) {
|
||||||
|
sh "docker cp ${WORKSPACE}/. ${containerId}:${APP_VOLUME}"
|
||||||
|
sh "docker start ${DOCKER_RELEASE_RUN_CONTAINER}"
|
||||||
|
} else {
|
||||||
|
error "Docker container ${DOCKER_RELEASE_RUN_CONTAINER} not found"
|
||||||
|
}
|
||||||
|
} else if (env.GIT_BRANCH == 'debug') {
|
||||||
|
// debug 브랜치용 작업
|
||||||
|
def containerId = sh(script: "docker ps -qf 'name=${DOCKER_DEBUG_RUN_CONTAINER}'", returnStdout: true).trim()
|
||||||
|
if (containerId) {
|
||||||
|
sh "docker cp ${WORKSPACE}/. ${containerId}:${APP_VOLUME}"
|
||||||
|
sh "docker start ${DOCKER_DEBUG_RUN_CONTAINER}"
|
||||||
|
} else {
|
||||||
|
error "Docker container ${DOCKER_DEBUG_RUN_CONTAINER} not found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
script {
|
||||||
|
def containerId = sh(script: "docker ps -qf 'name=${env.GIT_BRANCH == 'main' ? DOCKER_RELEASE_CONTAINER : DOCKER_DEBUG_CONTAINER}'", returnStdout: true).trim()
|
||||||
|
if (containerId) {
|
||||||
|
sh "docker logs ${containerId}"
|
||||||
|
} else {
|
||||||
|
echo "Docker container not found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo "Build failed. Check the console output for details."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user