Problem:
The job is being triggered successfully, but the file isn’t actually being uploaded to the Jenkins job. The job doesn’t seem to receive the file parameter, or it’s not being processed correctly.
Things I’ve Checked:
- The Jenkins job is configured to accept a file parameter.
- The parameter name used in the code matches the one in the Jenkins job.
- The API token and user credentials are correct.
const Jenkins = require('jenkins');
const fs = require('fs');
const jenkins = Jenkins({
baseUrl: 'http://your-username:your-api-token@your-jenkins-url',
});
async function triggerJobWithFile() {
try {
// Trigger the Jenkins job with a file parameter
const build = await jenkins.job.build({
name: 'your-job-name',
parameters: {
file: fs.createReadStream('/path/to/your/file.txt'),
},
});
console.log('Job triggered successfully:', build);
} catch (error) {
console.error('Failed to trigger job:', error.message);
}
}
triggerJobWithFile();```
**Questions:**
* Has anyone successfully used the Node.js `jenkins` client library to upload files to a Jenkins job?
* Are there any specific configurations or steps I might be missing?
* Is there a known issue with handling file parameters using this library?
Any insights or guidance would be greatly appreciated!
Thank you in advance for your help.