我有这个管道作业,需要像这样调用验证作业:
isHardReleaseAllowed= true
def versionOk = build(job: "/validateMVNVersion", parameters: [[$class: 'StringParameterValue', name: 'version', value: params.version],
[$class: 'BooleanParameterValue', name: 'isHardReleaseAllowed', value: isHardReleaseAllowed]], propagate: true)
validate作业定义如下:
string(name: 'version', description: 'The new version to set')
booleanParam(name: 'isReleaseTagAllowed',defaultValue: false , description: 'is hard release tag allowed?')
这些是我调用作业之前(从输出控制台)的值:
echo is使用isHardReleaseAllowed = true验证分支➡release/ testRelease上的1.12.14版本标记
但是当我在validateMVNVersion作业中回显它们时,
echo "isReleaseTagAllowed class : \u27A1" + isReleaseTagAllowed.getClass().toString() + " value :" + isReleaseTagAllowed
echo "env.isReleaseTagAllowed \u27A1" + env.isReleaseTagAllowed.getClass().toString() + " value :" + env.isReleaseTagAllowed
echo "params.isReleaseTagAllowed \u27A1" + params.isReleaseTagAllowed.getClass().toString() + " value :" + params.isReleaseTagAllowed
boolean isReleaseBranchAllowedBoolean = params.isReleaseTagAllowed == "true"
echo "Boolean asboolean value is " + isReleaseBranchAllowedBoolean
我得到这些值:
isReleaseTagAllowed class : ➡class java.lang.String value :false
[Pipeline] echo
env.isReleaseTagAllowed ➡class java.lang.String value :false
[Pipeline] echo
params.isReleaseTagAllowed ➡class java.lang.Boolean value :false
[Pipeline] echo
Boolean asboolean value is false
所有这些都是假的...我没有得到什么?
答案 0 :(得分:0)
获取值的一种好方法是设置正确的变量名;)