【发布时间】:2019-09-19 16:51:32
【问题描述】:
我正在使用声明式 Jenkins 管道。我有一个阶段可以从用户那里获得输入,例如
//Input
stage ('Manual Input'){
agent none
steps {
input message: "Please Approve", ok: 'Approve'
}
}
我不希望在 Jenkins 等待手动步骤完成时阻止任何代理,因此我使用了agent none。
我想知道是否有办法让这个阶段有条件地执行。
详细说明:
pipeline {
agent none
parameters {
choice(choices: "No\nYes",
description: 'Choose Yes to wait for Manual Input',
name: 'Input')
}
stages {
stage ('Stage_1'){
agent any
steps {
//Some Steps here
}
}
//Input stage which should only get executed if ${Input} is Yes
// Or else Directly go to Stage 3
stage ('Manual Input'){
agent none
steps {
input message: "Please Approve", ok: 'Approve'
}
}
stage ('Stage_3'){
agent any
steps {
//Some Steps here
}
}
}
}
我希望 Jenkins 执行“Stage_1”,然后仅当参数“Input”为“Yes”时才执行 Stage“Manual Input”,否则跳过“Manual Input”阶段并转到“Stage_3”。
由于agent none,我无法在“手动输入”阶段的script{} 块中执行if/else。它会引发错误。
非常感谢您的帮助! TIA
【问题讨论】:
标签: jenkins continuous-integration devops