当使用Jenkins管道时,是否有一种方法可以使用户响应输入()操作



考虑以下示例

node {
    stage('Build') {
        echo "do buildy things"
    }
    stage('Deploy') {
        hipchatSend(
            color: "PURPLE",
            message: "Holding for deployment authorization: ${env.JOB_NAME}, job ${env.BUILD_NUMBER}. Authorize or cancel at ${env.BUILD_URL}",
        )
        input('Push to prod?') //Block here until okayed.
        echo "Deployment authorized by ${some.hypothetical.env.var}"
        echo "do deploy things"
     }
}

响应输入时,单击按钮的用户名存储在构建日志中。

该用户名是在我可以使用的变量中提供的,例如另一个hipchatsend?

将字段submitterParameter供应input

def userName = input message: '', submitterParameter: 'USER'
echo "Accepted by ${userName}"

如果没有任何参数,则submitterParameter的值无关紧要。但是,如果您有参数,则它将指定保存值的数组元素的名称:

def ret = input message: '', parameters: [string(defaultValue: '', description: '', name: 'para1')], submitterParameter: 'USER'
echo "Accepted by ${ret['USER']}"

相关内容

最新更新