【发布时间】:2018-05-07 16:47:58
【问题描述】:
在我的 Jenkins 多分支管道中,我想在我的 Jenkinsfile 中使用以下代码:
def props = [
parameters([
string(
defaultValue: "Value1",
name: 'VALUE_NAME',
description: 'Something'),
string(
defaultValue: "Value2",
name: 'VALUE_NAME_v2',
description: 'Something else')
])]
properties(props)
if(condition1) {
// remove only VALUE_NAME
}
但我如何才能仅在条件 1 为真的情况下删除属性 VALUE_NAME? 我只找到了 sintax:
props.removeAll { it.toString().contains('VALUE_NAME')}
^^ 这会删除所有参数,即使我的变量没有像本例中那样具有公共主体的名称(“VALUE_NAME”)。
使用这个 sintax,一旦构建运行一次,我就无法在作业 UI 上看到“使用参数构建”按钮,而是“立即构建”。
【问题讨论】:
标签: jenkins jenkins-plugins jenkins-pipeline multibranch-pipeline