Jenkins Pipeline流水线发布 编译打包-发布测试-发布生产 一个任务搞定

转载自:https://www.jianshu.com/p/a1451a4d672d

Jenkins版本:Jenkins ver. 2.165

安装的插件:

 Pipeline
SSH Pipeline Steps

 

有些插件没有用到,由于是安装jenkins时默认安装的。

工作流程:

  1. 获取代码、编译打包
  2. 等待用户输入确认是否发布测试环境(或者预生产环境)
  3. 等待用户输入确认是否发布发布生产环境第一台主机
  4. 等待用户输入确认是否发布发布生产环境第二台主机

 

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'
    }
}

构建等待输入过程:

构建后视图显示:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值