1. 목표
- 젠킨스를 이용하여 백엔드 배포 자동화 및 무중단 배포
2. 준비물
git clone git@github.com:Oh-JunYoung/CowAPI.git
cd {project path}
chmod +x ./gradlew
./gradlew build
nohup java -jar {name}.jar &> /dev/null &
3. 젠킨스
echo "---build start---"
node {
stage('Clone') {
echo '>>> Git repository Clone'
git branch: 'dev', credentialsId: {credentialsId} , url: {git url}
}
stage('Move to Path') {
echo '>>> Move to Deploy Path'
sh 'sudo ./jenkins/MovePath.sh'
}
stage('Pull') {
echo '>>> Git repository Clone'
sh 'sudo ./jenkins/GitPull.sh'
}
stage('Build') {
echo '>>> Gradle project Build'
sh 'sudo ./jenkins/Build.sh'
}
stage('Test') {
echo '>>> Gradle project Test'
sh 'sudo ./jenkins/Test.sh'
}
stage('Kill') {
echo '>>> Gradle project Deploy'
sh 'sudo ./jenkins/KillProcess.sh'
}
stage('Deploy') {
echo '>>> Gradle project Deploy'
sh('JENKINS_NODE_COOKIE=dontKillMe && nohup ./jenkins/Deploy.sh &')
}
}
4. 결과