Skip to content

Commit

Permalink
Enable the ability to filter by view
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmichel committed May 4, 2015
1 parent c4e14af commit 544ff8a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/main.js
Expand Up @@ -16,6 +16,7 @@ var BUILDWITHPARAMS = '%s/job/%s/buildWithParameters';
var CONFIG = '%s/job/%s/config.xml';
var JOBINFO = '%s/job/%s' + API;
var LIST = '%s' + API;
var LIST_VIEW = '%s/view/%s' + API;
var LAST_SUCCESS = '%s/job/%s/lastSuccessfulBuild' + API;
var TEST_REPORT = '%s/job/%s/lastSuccessfulBuild/testReport' + API;
var LAST_BUILD = '%s/job/%s/lastBuild' + API;
Expand Down Expand Up @@ -112,6 +113,19 @@ var init = exports.init = function(host, options) {
callback(null, data);
});
},
all_jobs_in_view: function(view, callback) {
/*
Return a list of objet literals containing the name and color of all the jobs for a view on the Jenkins server
*/
request({method: 'GET', url: build_url(LIST_VIEW, view)}, function (error, response, body) {
if ( error || response.statusCode !== 200 ) {
callback(error || true, response);
return;
}
var data = JSON.parse(body.toString()).jobs;
callback(null, data);
})
},
job_info: function(jobname, callback) {
/*
Get all information for a job
Expand Down
12 changes: 12 additions & 0 deletions testjenkinsapi.js
Expand Up @@ -8,12 +8,24 @@ var jenkinsapi = require('./lib/main');

var jenkins = jenkinsapi.init("http://localhost:8080");

/*
jenkins.build('test', function(error, data) {
if (error) {
console.log(error);
}
console.log(data);
});
*/

/*
var view_name = "test";
jenkins.all_jobs_in_view(view_name, function (error, data) {
if (error) {
console.log(error);
}
console.log(data);
});
*/

/*
jenkins.all_jobs(function(error, data) { console.log(data)});
Expand Down

0 comments on commit 544ff8a

Please sign in to comment.