4

Pipeline Input Step

 2 years ago
source link: https://linuxsuren.github.io/blog/devops/jenkins/jenkins-plugin/pipeline-input-step/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Pipeline Input Step

Pipeline Input Step

该插件实现了一个在构建过程中 允许人工干预的功能,

源代码托管在 Jenkins 的官方仓库中。

它提供的 DSL 语句为 input,执行到该语句的时候,需要人工决定“通过”或者“拒绝”。它还支持设置允许点击”通过“的人或者组,以及 确认该操作时输入一些参数。

在下面的例子中,通过的话会打印用户输入的参数 name 的值;如果拒绝的话,当前流水线会直接失败

script {
    def approver = input id: 'approveId', message: 'need your approve', parameters: [string(defaultValue: '', description: 'Your name', name: 'name', trim: false), string(defaultValue: '', description: 'Your age', name: 'age', trim: false)]

    if (approver != null) {
        print approver.name
    } else {
        print "no data from approver"
    }
}

对于“通过”或者“拒绝“这样的操作,你可以使用 API 调用的方式来实现。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK