1. 목표
- 젠킨스를 이용하여 프론트 엔드 배포 자동화 및 무중단 배포
2. 준비물
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install --lts
node -e "console.log('Running Node.js ' + process.version)"
git clone git@github.com:Oh-JunYoung/CowAPI-Front.git
npm install
cd {project path}
npm run build
sudo vi /etc/nginx/sites-available/cowapi.conf
sudo nginx -t
sudo systemctl restart nginx
3. 젠킨스
- jenkins -> 플러그인 -> nodejs 설치
- jenkins 관리 -> global tool config
git update-index --add --chmod=+x {Filename}.sh
node {
echo "---build start---"
node {
stage('Clone') {
echo '>>> Git repository Clone'
git branch: 'feature/Jenkins', credentialsId: {credentialsId} , url: {git url}
}
stage('Move to Path') {
echo '>>> Move to Build Path'
sh './jenkins/MovePath.sh'
}
stage('Pull') {
echo '>>> Git repository Pull'
sh './jenkins/GitPull.sh'
}
stage('Build') {
echo '>>> React project Build'
nodejs('nodejs-16.16.0') {
sh './jenkins/Build.sh'
}
}
stage('Nginx') {
echo '>>> Nginx Restart'
sh './jenkins/Nginx.sh'
}
}