Jenkins - How to send boolean parameter using curl, http?

Viewed 1318

I am trying to send boolean parameter using curl, http-get to Jenkins without success. Need someone to tell me what is wrong here.

I did try to send it as true , True and 1 but none of this works.

Job in jenkins is set as pipeline and is parametrized. There are 3 parameters added from GUI:

  • bp1 boolean 1
  • bp2 boolean 2
  • sp string (this one is to check if parameters are send at all

Default values are as below:

  • bp1 - false
  • bp2 - false
  • sp - null

Pipeline code:

stage ('bools') {
    echo 'bool 1 is:' + params.bp1
    echo 'bool 2 is:' + params.bp2
    echo 'string is:' + params.sp
}

Command used to invoke build (in browser or postman):

http://X.X.X.X/jenkins/job/bool_debug/buildWithParameters?token=booltest&bp1=true&bp2=false$sp='this is text from param'

Expected result is bool 1 is:true but got bool 1 is:false. Jenkins did not change (tick checkbox) boolean parameter when invoking from API. In other means:

What I get:

Running in Durability level: MAX_SURVIVABILITY
[Pipeline] stage
[Pipeline] { (bools)
[Pipeline] echo
bool 1 is:false
[Pipeline] echo
bool 2 is:false
[Pipeline] echo
string is:'this is text from param'
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS

What it should be:

Running in Durability level: MAX_SURVIVABILITY
[Pipeline] stage
[Pipeline] { (bools)
[Pipeline] echo
bool 1 is:true    <--------------------------
[Pipeline] echo
bool 2 is:false
[Pipeline] echo
string is:'this is text from param'
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
Finished: SUCCESS
1 Answers

Faced with the same issue, think it's a Jenkins bug. I ended up creating another pipeline which triggers the desired pipeline with params as a workaround.

Related