考虑以下示例
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']}"