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