A patient library for automating your automation
You should not need this module.
Sometimes you can't control your corporate jenkins configuration, and have no choice but to trigger jobs manually. This library is made for that situation.
It can be installed globally and invoked from the command line, or imported and used as a part of another script.
jenkins-wait will trigger a job, and wait for it to start, and finish, exiting with or returning the status of the triggered job.
use in your project
npm install --save-dev jenkins-waitor globally
npm install --global jenkins-wait| option | required | default | description |
|---|---|---|---|
jenkins-base |
yes | Base jenkins url | |
job-location |
yes | Location of the job | |
username |
no | undefined |
username for basic auth |
password |
no | undefined |
password for basic auth |
poll-interval |
no | 1000 |
how long to wait before querying jenkins for build status |
use-https |
no | true |
use https protocol in making jenkins requests |
silent |
no | false |
suppress console output |
verbose |
no | false |
verbosely log all output, takes precedence over silent |
print-console |
no | false |
Print console output of the job after it completes |
parameters |
no | undefined |
colon-separated parameters to use for a parameterized build |
jenkins-wait [options]or use with npx
npx jenkins-wait [options]It will exit with 0 when the triggered job returns a status of SUCCESS and a 1 for all other statuses.
The library exposes the JenkinsTrigger class
Without parameters
const { JenkinsTrigger } = require('jenkins-wait');
const jenkinsJob = new JenkinsTrigger({
baseJenkins: 'ci.mycompany.com',
jobLocation: 'topLevel/myProject',
username: 'itsme',
password: 'securepassword',
pollInterval: 1000,
useHttps: true,
silent: false
});
jenkinsJob
.runJob()
.then(result => {
//do whatever you want with the result
})
.catch(error => {
// Make sure to handle errors!
});With parameters
const { JenkinsTrigger } = require('jenkins-wait');
const jenkinsJob = new JenkinsTrigger({
baseJenkins: 'ci.mycompany.com',
jobLocation: 'topLevel/myProject',
username: 'itsme',
password: 'securepassword',
pollInterval: 1000,
useHttps: true,
silent: true
});
jenkinsJob
.runJob({ keyOne: 'valueOne', keyTwo: 'valueTwo' })
.then(result => {
// Do whatever you want with the result
})
.catch(error => {
// Make sure to handle errors!
});When jenkins-wait is run from a CI environment (TravisCI, CircleCI, Jenkins, etc.) The running seconds count will not be printed to the console. When the CLI is used, it will also be run in verbose mode by default.
npm installnpm testnpm run buildHelpful for development
npm run build:watch