Build with parameters not working

154 views
Skip to first unread message

Nate

unread,
Jun 2, 2015, 4:48:52 PM6/2/15
to jenkins_a...@googlegroups.com
I have a Jenkins job, 'auto-pbuilder', that takes a couple of parameters.  When I try to trigger a build with parameters using the jenkins_api_client gem, the build is triggered, but the parameters are not sent over - the defaults are used instead. 

Below is my code.   According to the "Parameterized Build" page on the Jenkins wiki, the only examples given are passing parameters in the URL, but when I tcpdumped it looks like the parameters are being sent in the POST payload instead.

      job_name = "auto-pbuilder"
      job_params = { :DIST => 'precise', :tag => tag }
      client = JenkinsApi::Client.new(:server_ip => '10.10.10.10', :log_level => Logger::DEBUG, :log_location => '/var/tmp/jenkins.log')
      jenkins_job = JenkinsApi::Client::Job.new(client)
      return_code = jenkins_job.build(job_name, :params => job_params)

When I trigger this code and I tcpdump the connection to see what is going on, I do not see the build parameters being sent as URL arguments, instead they are being sent in the POST body.

20:08:43.437872 IP client.53368 > jenkins-1.webcache: Flags [P.], seq 1:219, ack 1, win 115, options [nop,nop,TS val 2245938866 ecr 1601428328], length 218
E....
@.@...
|?.
|>..x..mq_..+.)...s.......
..N._s.hPOST /job/auto-pbuilder/buildWithParameters HTTP/1.1
Accept: */*
User-Agent: Ruby
Content-Type: application/x-www-form-urlencoded
Connection: close
Host: 10.124.62.46:8080
Content-Length: 134


20:08:43.438086 IP jenkins-1.webcache > client.53368: Flags [.], ack 219, win 122, options [nop,nop,TS val 1601428329 ecr 2245938866], length 0
E..4.@@.@...
|>.
|?....x.+.)mq`....z5......
_s.i..N.
20:08:43.438100 IP client.53368 > jenkins-1.webcache: Flags [P.], seq 219:353, ack 1, win 115, options [nop,nop,TS val 2245938867 ecr 1601428329], length 134
E.....@.@..H
|?.
|>..x..mq`..+.)...s.......
..N._s.iparams=%7B%3ADIST%3D%3E%22precise%22%2C+%3Atag%3D%3E%222015.1%22%2C

So, if Jenkins is ignoring the parameters sent in the POST payload, does it need for the parameters to be sent in the URL?  And if so, how do I use the jenkins_api_client gem to effect that result?  Or am I doing this incorrectly?

Thanks,

--N.

Eric Fontana

unread,
Apr 14, 2016, 8:20:49 AM4/14/16
to jenkins_api_client
This code works for me:

@client.job.build('job name', { :param1 => 'Param value'})

Make sure you define param1 as a string parameter to 'job name'

Eric Fontana

unread,
Apr 14, 2016, 8:21:47 AM4/14/16
to jenkins_api_client
If you have more than one parameter, use { :param1 => 'p1', :param2 => 'p2' } 
Reply all
Reply to author
Forward
0 new messages