I came across an problem when trying to use jenkins.job.build(options, callback).
Under the options section for this it says you can use name (String): job name, parameters (Object, optional): build parameters, or token (String, optional): authorization token.
I was trying to trigger a Jenkins job remotely by selecting the Trigger builds remotely (e.g., from scripts) option in the configuration page of my Jenkins job. The Authentication token I used was 'test'. This was the code I was using to try and trigger that job:
Error: jenkins: job.build: bad request
at create (/PATH/TO/MY/DIRECTORY/node_modules/papi/lib/errors.js:14:5)
at Object.response [as Response] (/PATH/TO/MY/DIRECTORY/node_modules/papi/lib/errors.js:38:15)
at IncomingMessage.<anonymous> (/PATH/TO/MY/DIRECTORY/node_modules/papi/lib/client.js:592:26)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
It turns out that the fix to this problem was that if you are using the Trigger builds remotely (e.g., from scripts) option for your Jenkins job and you set an auth token of your choosing, then you MUST use the parameters option in your code like this:
I came across an problem when trying to use
jenkins.job.build(options, callback)
. Under the options section for this it says you can usename (String): job name
,parameters (Object, optional): build parameters
, ortoken (String, optional): authorization token
.I was trying to trigger a Jenkins job remotely by selecting the
Trigger builds remotely (e.g., from scripts)
option in the configuration page of my Jenkins job. The Authentication token I used was 'test'. This was the code I was using to try and trigger that job:This is error I kept getting in my terminal.
It turns out that the fix to this problem was that if you are using the
Trigger builds remotely (e.g., from scripts)
option for your Jenkins job and you set an auth token of your choosing, then you MUST use theparameters
option in your code like this:After I made that change it immediately worked.