即使传递了true,Jenkins DSL booleanCondition()也不返回true

时间:2017-06-15 04:14:06

标签: jenkins groovy jenkins-job-dsl

我有两个名为ParentJobChildJob的职位。 ParentJob会触发下游作业ChildJob

ParentJob我将变量传递给

parameters {
            predefinedProp('RELEASE','true')  
           }

ChildJob我选择参数为

conditionalSteps {
      condition {
        booleanCondition("RELEASE")
        steps {
          shell("echo 'Wow !!! condition is parsed as true'")
        }
      }

ChildJob的参数页面中,我可以看到它正确显示为true

enter image description here

仍然没有执行shell("echo 'Wow !!! condition is parsed as true'")行。在日志中,我可以看到:

09:35:41 Run condition [Boolean condition] enabling prebuild for step [BuilderChain]
09:35:41 [Boolean condition] checking [RELEASE] against [^(1|y|yes|t|true|on|run)$] (origin token: RELEASE)
09:35:41 Run condition [Boolean condition] preventing perform for step [BuilderChain]
09:35:41 Finished: SUCCESS

我甚至尝试从false作业中传递ParentJob,结果仍然相同。我做错了什么?

1 个答案:

答案 0 :(得分:0)

我错误地访问了令牌,其中正确的方式是booleanCondition('${RELEASE}')

这应该是正确的方法:

conditionalSteps {
      condition {
        booleanCondition('${RELEASE}')
        steps {
          shell("echo 'Wow !!! condition is parsed as true'")
        }
      }
    }