[JIRA] (JENKINS-40188) Unable to use build step with boolean parameterized parameter

7 views
Skip to first unread message

n27@3ds.com (JIRA)

unread,
Dec 2, 2016, 6:49:01 AM12/2/16
to jenkinsc...@googlegroups.com
aurelien leboulanger created an issue
 
Jenkins / Improvement JENKINS-40188
Unable to use build step with boolean parameterized parameter
Issue Type: Improvement Improvement
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2016/Dec/02 11:48 AM
Environment: pipeline model definition plugin version 0.6
Jenkins 2.25
Labels: pipeline jenkins
Priority: Blocker Blocker
Reporter: aurelien leboulanger

I'm not able to use both parameters and build with boolean parameter because the build step need a boolean value and i can only pass the value with a string:

#!/usr/bin/env groovy
pipeline {
    agent any

    parameters {
        booleanParam(defaultValue: false, description: 'Simulate the promotion', name: 'SIMUL')
    }

    stages {
        stage('promote') {
            steps {
                build job: 'promote', parameters: [
                    booleanParam(name: 'SIMUL', value: "${env.SIMUL}")
                ]
            }
        }
    }
}

will generate this kind of error:

java.lang.ClassCastException: hudson.model.BooleanParameterValue.value expects boolean but received class java.lang.String
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Dec 8, 2016, 5:09:02 PM12/8/16
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Improvement JENKINS-40188
 
Re: Unable to use build step with boolean parameterized parameter

My first thought is to just try value: env.SIMUL - in relatively recent versions of the various Pipeline plugins, you can actually just use value: SIMUL, for that matter. Let me know if that helps?

n27@3ds.com (JIRA)

unread,
Dec 9, 2016, 2:58:01 AM12/9/16
to jenkinsc...@googlegroups.com

booleanParam(name: 'SIMUL', value: env.SIMUL) not works:

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

n27@3ds.com (JIRA)

unread,
Dec 16, 2016, 5:50:01 AM12/16/16
to jenkinsc...@googlegroups.com
[~abayer]
{{booleanParam(name: 'SIMUL', value: env.SIMUL)}} not works:


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

n27@3ds.com (JIRA)

unread,
Dec 16, 2016, 8:52:01 AM12/16/16
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Dec 19, 2016, 3:57:02 PM12/19/16
to jenkinsc...@googlegroups.com
Andrew Bayer edited a comment on Bug JENKINS-40188
 
Re: Unable to use build step with boolean parameterized parameter
[~herau] Hrm. So, with {{workflow-job}} 2.8 installed, {{booleanParam(name: 'SIMUL', value: env.SIMUL)}} works - see https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/75 for an example based on yours. {{" \ $ \ {env.PARAM}"}} definitely does *not* work, but {{env.PARAM}} does.

andrew.bayer@gmail.com (JIRA)

unread,
Dec 19, 2016, 3:57:02 PM12/19/16
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Dec 19, 2016, 3:57:02 PM12/19/16
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-40188
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Dec 19, 2016, 3:57:02 PM12/19/16
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-40188
 
Re: Unable to use build step with boolean parameterized parameter

aurelien leboulanger Hrm. So, with workflow-job 2.8 installed, booleanParam(name: 'SIMUL', value: env.SIMUL) works - see https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/75 for an example based on yours. {{"$

{env.PARAM}

"}} definitely does not work, but env.PARAM does.

andrew.bayer@gmail.com (JIRA)

unread,
Dec 19, 2016, 3:57:03 PM12/19/16
to jenkinsc...@googlegroups.com
Andrew Bayer edited a comment on Bug JENKINS-40188
[~herau] Hrm. So, with {{workflow-job}} 2.8 installed, {{booleanParam(name: 'SIMUL', value: env.SIMUL)}} works - see https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/75 for an example based on yours. {{" \ ${env.PARAM}"}} definitely does *not* work, but {{env.PARAM}} does.

andrew.bayer@gmail.com (JIRA)

unread,
Dec 19, 2016, 3:58:01 PM12/19/16
to jenkinsc...@googlegroups.com

n27@3ds.com (JIRA)

unread,
Dec 20, 2016, 3:09:02 AM12/20/16
to jenkinsc...@googlegroups.com
aurelien leboulanger commented on Bug JENKINS-40188
 
Re: Unable to use build step with boolean parameterized parameter

The workflow-job is a sub-plugin right ? Does this will be able in the next release of the model definition plugin ?
Thanks for you pull request

n27@3ds.com (JIRA)

unread,
Dec 20, 2016, 3:13:01 AM12/20/16
to jenkinsc...@googlegroups.com
The workflow-job is a sub-plugin right ? Moreover the current version of this plugin is already 2.9. Does this will be able in the next release of the model definition plugin ?

Thanks for you pull request

andrew.bayer@gmail.com (JIRA)

unread,
Dec 20, 2016, 12:10:01 PM12/20/16
to jenkinsc...@googlegroups.com

You should be able to use params.PARAM now if you've got workflow-job 2.8 or later installed, yeah.

n27@3ds.com (JIRA)

unread,
Dec 21, 2016, 7:42:02 AM12/21/16
to jenkinsc...@googlegroups.com

i'm using pipeline-model-definition (version:0.6), so i'm using workflow-job 2.8 but this syntax doesn't works.

#!/usr/bin/env groovy
pipeline {
    agent any
    parameters {
        booleanParam(defaultValue: false
, description: 'Simulate the promotion', name: 'SIMUL')
    }
    stages {
        stage('promote') {
            steps {
                build job: 'promote', parameters: [
                    booleanParam(name: 'SIMUL', value: env.SIMUL)
                ]
            }
        }
    }
}

will generate this exception : java.lang.ClassCastException: hudson.model.BooleanParameterValue.value expects boolean but received class java.lang.String

andrew.bayer@gmail.com (JIRA)

unread,
Dec 22, 2016, 9:41:01 AM12/22/16
to jenkinsc...@googlegroups.com

Right, try params.SIMUL, rather than env.SIMUL.

n27@3ds.com (JIRA)

unread,
Dec 22, 2016, 9:44:01 AM12/22/16
to jenkinsc...@googlegroups.com
my bad... thanks [~abayer] it's work now :-)

n27@3ds.com (JIRA)

unread,
Dec 22, 2016, 9:44:01 AM12/22/16
to jenkinsc...@googlegroups.com

pwolf@cloudbees.com (JIRA)

unread,
Dec 23, 2016, 3:10:01 PM12/23/16
to jenkinsc...@googlegroups.com

Andrew Bayer aurelien leboulanger I came across this a few weeks ago as well and found that it works if I don't use all CAPS.

This works:

 parameters{
        booleanParam(defaultValue: true, description: '', name: 'skip')
    }

This would not:

 parameters{
        booleanParam(defaultValue: true, description: '', name: 'SKIP')
    }

scm_issue_link@java.net (JIRA)

unread,
Jan 4, 2017, 1:34:02 PM1/4/17
to jenkinsc...@googlegroups.com

Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-definition/pom.xml
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
pipeline-model-definition/src/test/resources/booleanParamBuildStep.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/1db58160e0fdb41a14cb73523a1297070072ef0f
Log:
JENKINS-40188 Test to verify that boolean params can be passed on.

Can't actually reproduce the issue with 'env.PARAM' or 'params.PARAM',
but can with '"$

{env.PARAM}

"'. If there's a deeper problem here, it's
that we're not actually validating the parameters to the parameters of
steps themselves, but that's a different matter.

scm_issue_link@java.net (JIRA)

unread,
Jan 4, 2017, 1:34:04 PM1/4/17
to jenkinsc...@googlegroups.com

Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-definition/pom.xml
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
pipeline-model-definition/src/test/resources/booleanParamBuildStep.groovy

JENKINS-40188 Test to verify that boolean params can be passed on.

andrew.bayer@gmail.com (JIRA)

unread,
Jan 4, 2017, 1:35:02 PM1/4/17
to jenkinsc...@googlegroups.com
Andrew Bayer resolved as Not A Defect
 
Change By: Andrew Bayer
Status: In Progress Resolved
Resolution: Not A Defect

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:24:40 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Not A Defect
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages