如何将管道中的布尔参数值传递给下游作业? [英] How to pass boolean parameter value in pipeline to downstream jobs?

查看:111
本文介绍了如何将管道中的布尔参数值传递给下游作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有集成交付管道功能的Jenkins v2.1( https://jenkins.io/解决方案/管道/)来协调两个现有构建(构建和部署).

I'm using Jenkins v2.1 with the integrated delivery pipeline feature (https://jenkins.io/solutions/pipeline/) to orchestrate two existing builds (build and deploy).

在我的参数化构建中,我有3个用户参数设置,这也需要在管道中选择.

In my parameterized build I have 3 user parameters setup, which also needs to be selectable in the pipeline.

管道脚本如下:

node: {
    stage 'build'
    build job: 'build', parameters: [[$class: 'StringParameterValue', name: 'target', value: target], [$class: 'ListSubversionTagsParameterValue', name: 'release', tag: release], [$class: 'BooleanParameterValue', name: 'update_composer', value: update_composer]]

    stage 'deploy'
    build job: 'deploy', parameters: [[$class: 'StringParameterValue', name: 'target', value: target]]
}

BooleanParameterValue之外,此方法均正常工作.当我构建管道时,会引发以下错误:

This works correctly except for the BooleanParameterValue. When I build the pipeline the following error is thrown:

java.lang.ClassCastException: hudson.model.BooleanParameterValue.value expects boolean but received class java.lang.String

如何解决此类型转换错误? 甚至更好的是,是否可以通过一种简便的方法将所有管道参数传递给下游作业.

How can I resolve this typecasting error? Or even better, is there a less cumbersome way in which I can just pass ALL the pipeline parameters to the downstream job.

推荐答案

假设

value: update_composer

是问题,请尝试

value: Boolean.valueOf(update_composer)

有没有那么麻烦的方法,我可以将所有管道参数传递给下游作业

is there a less cumbersome way in which I can just pass ALL the pipeline parameters to the downstream job

据我所知,至少没有使用Jenkins API调用并禁用Groovy沙箱的情况.

Not that I know of, at least not without using Jenkins API calls and disabling the Groovy sandbox.

这篇关于如何将管道中的布尔参数值传递给下游作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆