npm install jenkins-api
var jenkinsapi = require('jenkins-api');
var jenkins = jenkinsapi.init("http://jenkins.yoursite.com");
// or with auth
var jenkins = jenkinsapi.init("http://username:password@jenkins.yoursite.com");
jenkins.all_jobs(function(err, data) {
if (err){ return console.log(err); }
console.log(data)
});
jenkins.job_info('job-in-jenkins', function(err, data) {
if (err){ return console.log(err); }
console.log(data)
});
jenkins.build_info('job-in-jenkins', 'build-number', function(err, data) {
if (err){ return console.log(err); }
console.log(data)
});
jenkins.last_build_info('job-in-jenkins', function(err, data) {
if (err){ return console.log(err); }
console.log(data)
});
jenkins.last_build_report('job-in-jenkins', function(err, data) {
if (err){ return console.log(err); }
console.log(data)
});
jenkins.get_config_xml('job-in-jenkins', function(err, data) {
if (err){ return console.log(err); }
console.log(data)
});
jenkins.copy_job('job-to-copy'
,'new-job-title'
,function(config) {
// function which takes the config.xml, and returns
// the new config xml for the new job
return config.replace('development','feature-branch');
}
,function(error, data) {
// if no error, job was copied
if (err){ return console.log(err); }
console.log(data)
});
jenkins.delete_job('job-in-jenkins', function(err, data) {
if (err){ return console.log(err); }
console.log(data)
});
jenkins.last_success('job-in-jenkins', function(err, data) {
if (err){ return console.log(err); }
console.log(data)
});
jenkins.last_result('job-in-jenkins', function(err, data) {
if (err){ return console.log(err); }
console.log(data)
});
Modeled after the Python Jenkins API