gpt4 book ai didi

Jenkins 声明式管道 - 仅当满足条件时如何添加输入步骤

转载 作者:行者123 更新时间:2023-12-02 19:37:38 24 4
gpt4 key购买 nike

我的管道中有一个输入阶段,我希望仅在满足特定条件时才运行。

    stage ('input stage') {
agent none
when {
expression {
condition1 == "YES"
}
}
input {
message 'Proceed with this step?'
submitter "${approvers}"
}
steps {
echo "Proceeding with step..."
}
}

但是,即使不满足条件,输入阶段也会等待提交者批准。

我假设这对于有输入的阶段是可能的。上面的代码块有问题吗?

提前致谢。

最佳答案

不存在“问题”,只是input directive如何声明性管道工程(重点是我的):

The input directive on a stage allows you to prompt for input, using the input step. The stage will pause after any options have been applied, and before entering the agent block for that stage or evaluating the when condition of the stage. If the input is approved, the stage will then continue.

要在input之前检查when条件,请将input变成一个步骤:

stage ('input stage') {
agent none
when {
expression {
condition1 == "YES"
}
}
steps {
input message: 'Proceed with this step?', submitter: "${approvers}"
echo "Proceeding with step..."
}
}

关于Jenkins 声明式管道 - 仅当满足条件时如何添加输入步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60830678/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com