1.2.7 • Published 6 years ago
@wkronmiller/node-jenkins v1.2.7
node-jenkins
Usage
Create an instance
Options
- jenkinsId:
Stringusually the email you use to log into your jenkins. - jenkinsToken:
Stringyou can find it in your jenkins personal area. - jenkinsPath:
Stringthe url you use to acces to your jenkins. - customHeaders:
Objectdefault={}with custom headers to be sended in every request (don't worry about the 'Authorization' or 'crumb' headers, node-jenkins do it for you :wink: ).
import Jenkins from "node-jenkins";
const jenkins = new Jenkins(jenkinsId, jenkinsToken, jenkinsPath, [
customHeaders
]);Info
Retrieve server information.
const info = await jenkins.info();Jobs
Retrieve job information
- jobName:
Stringjob url
const info = await jenkins.info(jobName);Retrieve job configuration
- jobUrl:
Stringjob url
const config = await jenkins.getJobConfig(jobUrl);Builds
Retrieve build information
- jobName:
Stringjob url - jobId:
Numberbuild id
const info = await jenkins.getBuildInfo(jobName, jobId);Trigger build with parameters
- jobName:
Stringjob url - params:
Objectdefault={}params to send to job building
const build = await jenkins.buildWithParams(jobName, [params]);Trigger build now
- jobName:
Stringjob url
const build = await jenkins.build(jobName);Show progressive console output
- jobName:
Stringjob url - jobId:
Numberbuild id - showLogs:
Booleandefault=trueyou can execute this function without displaying logs on console, only to waiting for the build finish - interval:
Numberdefault=100interval to retrieve next output in milliseconds
await jenkins.progressiveText(jobName, jobId, [showLogs, interval]);Note that in all examples i use async/await, you can use .then instead
License
This work is licensed under the MIT License (see the LICENSE file).