Jenkins Pipeline流水線發布 編譯打包-發布測試-發布生產 一個任務搞定
https://www.jianshu.com/p/a1451a4d672d
0.096
字數 142閱讀 2,392
Jenkins版本:Jenkins ver. 2.165
安裝的插件:

image.png

image.png
有些插件沒有用到,由於是安裝jenkins時默認安裝的。
工作流程:
- 獲取代碼、編譯打包
- 等待用戶輸入確認是否發布測試環境(或者預生產環境)
- 等待用戶輸入確認是否發布發布生產環境第一台主機
- 等待用戶輸入確認是否發布發布生產環境第二台主機

image.png

image.png
Pipeline script:
node {
stage('build'){
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '44222250-cfd7-45f4-558e-209f410fddc9', url: 'http://jenkins@git.gitlab.com/aaa/aaa.git']]])
sh label: '', script: 'mvn clean package install'
}
stage('push_uat') {
timeout(time: 7, unit: 'DAYS') {
input message: '是否發布到預生產?',ok: 'Yes'
}
sh label: '', script: '/shell/deploy_v2.sh uat'
}
stage('push_online1') {
timeout(time: 7, unit: 'DAYS') {
input message: '是否發布到生產online1?',ok: 'Yes'
}
sh label: '', script: '/shell/deploy_v2.sh online1'
}
stage('push_online2') {
timeout(time: 7, unit: 'DAYS') {
input message: '是否發布到生產online2?',ok: 'Yes'
}
sh label: '', script: '/shell/deploy_v2.sh online2'
}
}
構建等待輸入過程:

image.png
構建后視圖顯示:

image.png