Front/Jenkinsfile
seonkyu.kim 7c7a9d4fd7
Some checks failed
Front/pipeline/head There was a failure building this commit
[👷] Jenkins Test
2024-07-12 12:36:50 +09:00

42 lines
1.3 KiB
Groovy

pipeline {
agent any
environment {
DOCKER_CONTAINER_NAME = 'stein-node'
APP_VOLUME_FRONT = '/home/node/front' // 컨테이너 내부 경로
}
stages {
stage('Clone Repository') {
steps {
git url: 'http://your-gitea-repo2-url.git', branch: 'main'
}
}
stage('Build and Test') {
steps {
dir('front') {
sh 'npm install'
sh 'npm test'
}
}
}
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}/front/. ${containerId}:${APP_VOLUME_FRONT}"
// 컨테이너 재시작
sh "docker restart ${containerId}"
} else {
error "Docker container ${DOCKER_CONTAINER_NAME} not found"
}
}
}
}
}
}