詹金斯建造确认书

时间:2019-09-27 07:03:12

标签: jenkins

我有一些带有参数的构建,其中一个参数是environment [将显示3个下拉选项]。

我要确保用户选择了正确的环境进行部署

用户选择带有参数的构建后,jenkins中是否有任何方法,然后它将要求进行确认

    Are you sure you want to deploy to prod env yes or no

如果是,它将继续构建,如果不需要,则将继续构建

关于这种方法的任何想法

谢谢

2 个答案:

答案 0 :(得分:1)

插件Pipeline: Input Step提供了这样的功能。

  

message此参数给出一个提示,该提示将显示给人类:

Ready to go?
Proceed or Abort
If you click "Proceed" the build will proceed to the next step, if you click "Abort" the build will be aborted.

可以在here中找到该插件的API。有很多配置可能性,所以我相信您会发现自己的情况。

答案 1 :(得分:0)

您可以在jenkinsfile中执行类似的操作

node('docker'){ withMaven(jdk:'jdk8',maven:'maven 3.5.0'){

    stage('checkout') {
        // do checkout
    }

    def runRelease = true;
    try {
        // In the console logs
        // Will ask you to Proceed a release (60 sconds temporisation)
        // after 60s runRelease is evaluated to false in exception block
        timeout(time: 60, unit: 'SECONDS') {
            input 'Faire une release ?'
        }
    } catch (err) {
        runRelease = false;
        def user = err.getCauses()[0].getUser()
        if('SYSTEM' == user.toString()) { // SYSTEM means timeout.
            echo "Aborted by System (timeout)"
        } else {
            echo "Aborted by: [${user}]"
        }
    }

    if(runRelease) {
        stage('release') {
            // do the release buld
        }
    } else {
        // do other builds
    }
}

}