我试图将变量sampleArray传递给activeChoiceReactiveParam的groovyScript函数,不幸的是,生成的xml没有选择值。我在这个操场上试过了,http://job-dsl.herokuapp.com,以及真正的詹金斯,结果都不管用。我的意思是sampleArray的价值不是被复制的。请告诉我如何实现这一点。
job("try-to-pass-array") {
def sampleArray = ["one","two","three","four"]
description("this is to test a element type")
keepDependencies(false)
parameters {
activeChoiceReactiveParam('NUMBERS') {
description('Choose numbers for which build has to be generated')
choiceType('MULTI_SELECT')
groovyScript {
script('return $sampleArray')
fallbackScript('"fallback choice"')
}
}
}
disabled(false)
concurrentBuild(false)
steps {
shell('''
echo $NUMBERS
''')
}
}发布于 2019-11-22 06:37:09
您没有使用正确的字符串插值。jenkins (声明管道)文档有一个很好的例子。
def username = 'Jenkins'
echo 'Hello Mr. ${username}'
echo "I said, Hello Mr. ${username}"将导致:
Hello Mr. ${username}
I said, Hello Mr. Jenkins因此,如果要传递变量的值,请始终使用"而不是'。
tl; script("return ${sampleArray}")博士
https://stackoverflow.com/questions/58980698
复制相似问题