AcaMate_API/Jenkinsfile
seonkyu.kim 877ec7d232
Some checks failed
AcaMate-API/pipeline/head There was a failure building this commit
[📝] Jenkins 수정
2024-11-04 17:53:54 +09:00

57 lines
1.9 KiB
Groovy

pipeline {
agent any
environment {
DOCKER_RELEASE_CONTAINER = 'acamate-back-build-release'
DOCKER_DEBUG_CONTAINER = 'acamate-back-build-debug'
APP_VOLUME = '/src'
}
stages {
stage('Clone Repository') {
steps {
git url: 'https://git.ipstein.myds.me/AcaMate/AcaMate_API.git', branch: env.BRANCH_NAME
}
}
stage('Deploy') {
steps {
script {
if (env.GIT_BRANCH == 'main') {
// main 브랜치용 작업
def containerId = sh(script: "docker ps -qf 'name=${DOCKER_RELEASE_CONTAINER}'", returnStdout: true).trim()
if (containerId) {
sh "docker cp ${WORKSPACE}/. ${containerId}:${APP_VOLUME}"
sh "docker start ${containerId}"
} else {
error "Docker container ${DOCKER_RELEASE_CONTAINER} not found"
}
} else if (env.GIT_BRANCH == 'debug') {
// debug 브랜치용 작업
def containerId = sh(script: "docker ps -qf 'name=${DOCKER_DEBUG_CONTAINER}'", returnStdout: true).trim()
if (containerId) {
sh "docker cp ${WORKSPACE}/. ${containerId}:${APP_VOLUME}"
sh "docker start ${containerId}"
} else {
error "Docker container ${DOCKER_DEBUG_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."
}
}
}