Jenkins Pipeline流水線發布 編譯打包-發布測試-發布生產 一個任務搞定


Jenkins Pipeline流水線發布 編譯打包-發布測試-發布生產 一個任務搞定

https://www.jianshu.com/p/a1451a4d672d

0.096 字數 142閱讀 2,392

Jenkins版本:Jenkins ver. 2.165

安裝的插件:

Pipeline
SSH Pipeline Steps

 
image.png

 

 
image.png

有些插件沒有用到,由於是安裝jenkins時默認安裝的。

工作流程:

  1. 獲取代碼、編譯打包
  2. 等待用戶輸入確認是否發布測試環境(或者預生產環境)
  3. 等待用戶輸入確認是否發布發布生產環境第一台主機
  4. 等待用戶輸入確認是否發布發布生產環境第二台主機
 
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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM