silas / node-jenkins

Jenkins client
https://www.npmjs.com/package/jenkins
MIT License
356 stars 85 forks source link

the official demo that's jenkins.job.build with parameters can't work #83

Closed duian closed 5 years ago

duian commented 5 years ago

that's code

var jenkins = require('jenkins');
jenkins = jenkins({
  baseUrl: 'http://USER:PASSWORD@HOST:PORT',
  crembIsuser: true,
});
// without params is work
 jenkins.job.build(JOB_NAME, (err, data) => {
     if (err) throw err;
     res.send({ data });
 });

// it's not work
jenkins.job.build({ name: JOB_NAME, parameters: { name: 'value' },  token: 'token' }, function(err) {
    if (err) throw err;
 });

// it's not work
jenkins.job.build({ name: JOB_NAME, parameters: { name: 'value' } }, function(err) {
    if (err) throw err;
 });

terminal output this error message:

/Users/jenkins-api/routes/jenkins.js:59
    if (err) throw err;
             ^
Error: jenkins: job.build: internal server error
    at create (/Users/duian/Work/jenkins-api/node_modules/papi/lib/errors.js:14:5)
    at Object.response [as Response] (/Users/duian/Work/jenkins-api/node_modules/papi/lib/errors.js:38:15)
    at IncomingMessage.<anonymous> (/Users/duian/Work/jenkins-api/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:1055:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

I set Trigger builds remotely (e.g., from scripts) in job settings and Authentication Token is token.

duian commented 5 years ago

I forget setting parameters in job settings