Overriding default boolean parameter value from false to true when building one Jenkins pipeline from another

Viewed 2149

I have 2 declarative jenkins pipeline, "A" and "B".

"B" has a boolean parameter named "TEST" with the default value as 'false'.

I am calling pipeline "B" from "A" as below:

build job: 'B', parameters:[booleanParam(name: 'TEST', value:'true')], wait: true

However, the pipeline "B" is getting executed with the default value of 'false' only.

I tried toBoolean() method as well, however, it was blocked during the pipeline execution stating requires script approval.

I found another post related to it: Overriding default parameter when building one Jenkins pipeline from another

But no solution there too.

Any suggestions.

2 Answers

I think the problem is you are passing "true" as a string. Try just value: true

I found the issue. The problem was with the setting of the default value.

Wrong declaration: the defaultValue false was declared within single quotes

 booleanParam (
                    name: 'TEST',
                    defaultValue: 'false',
                    description: 'Test?'
                    )

Correct declaration: the defaultValue false was declared without any quotes

 booleanParam (
                    name: 'TEST',
                    defaultValue: false,
                    description: 'Test?'
                    )

Now, when I have passed the value as: value: true, it worked fine. Thanks @smelm, your tip helped me in finding the root cause.

Related