我有一个Jenkins管道,它应该评估一个名为saveEar
的布尔参数:
stage ('Publish to CIFS'){
echo String.valueOf(saveEar)
if ( saveEar ) {
cifsPublisher alwaysPublishFromMaster: false, continueOnError: false, failOnError: false, publishers: [[
configName: 'MY-CONFIG', transfers: [[
cleanRemote: false,
excludes: '',
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: "jenkins-job_" + '$JOB_NAME' + '$BUILD_NUMBER',
remoteDirectorySDF: false,
removePrefix: 'build/libs',
sourceFiles: 'build/libs/my.ear']],
usePromotionTimestamp: false,
useWorkspaceInPromotion: false,
verbose: true
]]
}
}
这是参数配置:
<hudson.model.BooleanParameterDefinition>
<name>saveEar</name>
<description>valore per scegliere se salvare l'EAR generato su XXXX (true => salva, default false)</description>
<defaultValue>false</defaultValue>
</hudson.model.BooleanParameterDefinition>
我希望当saveEar
为false
时,Jenkins不会通过CIFS发布,但事实并非如此。
这是管道日志:
[Pipeline] stage
[Pipeline] { (Publish to CIFS)
[Pipeline] echo
false
[Pipeline] cifsPublisher
CIFS: Connecting from host [jenkins.mydomain]
CIFS: Connecting with configuration [MY-CONFIG] ...
CIFS: Removing WINS from name resolution
CIFS: Setting response timeout [30.000]
CIFS: Setting socket timeout [35.000]
<...>
CIFS: Transferred 1 file(s)
[Pipeline] }
有人可以帮忙澄清这个问题吗?
答案 0 :(得分:4)
要访问管道阶段中的参数,请使用params.variableName
。在您的情况下,您应该使用params.saveEar
来访问该值。