jenkins Pipeline
Last updated on November 20, 2024 am
🧙 Questions
通过构建pipeline实现,前端项目的打包
☄️ Ideas
创建pipeline
配置jenkins的ssh免密访问代码库
# 使用root用户切jenkins用户
su jenkins
cat /var/lib/jenkins/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6WJZuBA5veNhf645RTDXLNmIPYx4jAIkTB1bT4lOn5EHicNb7AfBKLk9+NkMvgyRLpoqoyQDB2/AwdSvbangte1ERysl+ubEBBUViW733zcAjGXm+enpISXv+bpxz7O7NayWhjvWT/T4nOwS34UC9hiXLH5kDBqon6840fSxVz4OXrCdp5VQ2inZH1JEABQqTBUc3g9XFvE++JoN134s4iyzE+r+JCs796n+AzTaySMocx95/IZOw1E/FtIfZx5eL5XwtzFqY4dNVzQM6gtXkFvMGYFDURhuf2VZmXgvJ049400D9KC/0hVrLk9xsZ0vQ1JBMSySfzPeVjtYo3roF jenkins@iZ8vbf01lf4onq990stdn3Z
配置pipeline
可以使用自定义密钥
git branch: ‘dev’, credentialsId: ‘8f91b161-5cce-479a-82af-e31ffdb159f2’, url: ‘http://git.definesys.com/ispong/ispong_admin.git'
// agent {
// label 'master'
// }
node('master') { {
stage('checkout') {
git branch: 'dev',url: 'git@git.dfy.definesys.cn:ispong/ispong-xapp.git'
}
stage('install') {
sh "nrm use devin"
sh "npm install"
}
stage('build') {
sh "node --max_old_space_size=8192 ./node_modules/.bin/vue-cli-service build --mode ${MODE}"
}
}
node {
stage('checkout') {
git branch: "${BRANCH}",url: 'git@git.dfy.definesys.cn:ispong/ispong-xapp.git'
}
stage('rm node_modules') {
try {
sh "rm -rf ./package-lock.json"
// sh "rm -rf ./node_modules/"
} catch(e) {}
}
stage('install') {
sh "nrm use devin"
sh "npm install"
}
stage('build') {
sh "NODE_ENV=production node --max_old_space_size=4196 ./node_modules/.bin/vue-cli-service build --mode ${MODE}"
try {
sh "rm -rf ./ispong-xapp.zip"
} catch(e) {}
sh "zip -r ispong-xapp.zip ./dist"
}
stage('trigger deploy') {
if ("true" == "${DEPLOY}") {
if('dev' == "${BRANCH}"){
sh "curl http://jenkins.dfy.definesys.cn/view/ispong-dev/job/ispong-web-app-deploy/build?token=ispong_web_deploy"
}else if('demo' == "${BRANCH}"){
sh "curl http://jenkins.dfy.definesys.cn/view/ispong-dev/job/ispong-web-app-deploy-demo/build?token=ispong_web_deploy"
}
}
}
}
🔗 Links
jenkins Pipeline
https://ispong.isxcode.com/kubernetes/jenkins/jenkins Pipeline/