我有一个带有一些布尔参数的管道。我想按in the docs的说明添加quietPeriod
,但是我在努力使语法正确。我尝试过:
properties([
parameters :[
booleanParam(name: 'foo', defaultValue: false, description: 'bar')
],
quietPeriod: 10
])
但这会产生一个
java.lang.UnsupportedOperationException: must specify $class with an implementation of interface java.util.List
。
有人知道如何正确添加此参数吗?
答案 0 :(得分:0)
将其用作管道中的option
,如下所示:
pipeline {
agent any
options {
quietPeriod(300) //Quiet period in seconds
}
stages {
stage('1') {
steps {
println("Hello")
}
}
}
}
答案 1 :(得分:0)
从 JIRA 中的这个 Jenkins ticket 来看,该功能似乎只有在使用声明式流水线语法时才默认可用。
作为一种解决方法,我发现这样做
currentBuild.rawBuild.getParent().setQuietPeriod(210)
就像一个魅力。设置好属性后就可以直接放了,像这样:
properties([
parameters :[
booleanParam(name: 'foo', defaultValue: false, description: 'bar')
]
])
currentBuild.rawBuild.getParent().setQuietPeriod(210)