Permalink
Browse files

Add doco on newly added methods.

  • Loading branch information...
1 parent 02f63c3 commit 4f7eee337c14747a4bd86c4eb2fd2b8c34353de6 @cliffano committed Feb 13, 2014
Showing with 54 additions and 1 deletion.
  1. +54 −1 lib/jenkins.js
View
@@ -377,6 +377,14 @@ Jenkins.prototype.job = function (name, cb) {
req.request('get', this.url + '/job/' + name + '/api/json', this.opts, cb);
};
+/**
+ * Enable a job.
+ * If job was disabled, then it will be enabled.
+ * If job was already enabled, then it will stay as-is, no error.
+ *
+ * @param {String} jobName: Jenkins job name
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Jenkins.prototype.enable = function (jobName, cb) {
var self = this;
@@ -395,6 +403,14 @@ Jenkins.prototype.enable = function (jobName, cb) {
req.request('post', this.url + '/job/' + jobName + '/enable', this.opts, cb);
};
+/**
+ * Disable a job.
+ * If job was enabled, then it will be disabled.
+ * If job was already disabled, then it will stay as-is, no error.
+ *
+ * @param {String} jobName: Jenkins job name
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Jenkins.prototype.disable = function (jobName, cb) {
var self = this;
@@ -413,6 +429,14 @@ Jenkins.prototype.disable = function (jobName, cb) {
req.request('post', this.url + '/job/' + jobName + '/disable', this.opts, cb);
};
+/**
+ * Create a new job by providing a configuration file
+ * containing Jenkins config.xml .
+ *
+ * @param {String} jobName: Jenkins job name
+ * @param {String} configFile: path to configuration file
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Jenkins.prototype.create = function (jobName, configFile, cb) {
function _success(result, cb) {
@@ -438,13 +462,22 @@ Jenkins.prototype.create = function (jobName, configFile, cb) {
req.request('post', this.url + '/createItem/api/json', this.opts, cb);
};
+/**
+ * Update an existing job by providing a configuration file
+ * containing Jenkins config.xml .
+ *
+ * @param {String} jobName: Jenkins job name
+ * @param {String} configFile: path to configuration file
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Jenkins.prototype.update = function (jobName, configFile, cb) {
function _success(result, cb) {
cb();
}
- this.opts.queryStrings = { name: jobName };
+// TODO
+///// this.opts.queryStrings = { name: jobName };
// this.opts.headers = { 'content-type': 'application/xml' };
this.opts.body = fs.readFileSync(configFile).toString();
@@ -458,6 +491,13 @@ Jenkins.prototype.update = function (jobName, configFile, cb) {
req.request('post', this.url + '/job/' + jobName + '/config.xml', this.opts, cb);
};
+/**
+ * Copy an existing job into a new job.
+ *
+ * @param {String} sourceJobName: Jenkins job name to copy from
+ * @param {String} newJobName: Jenkins job name to copy to
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Jenkins.prototype.copy = function (sourceJobName, newJobName, cb) {
function _success(result, cb) {
@@ -482,6 +522,12 @@ Jenkins.prototype.copy = function (sourceJobName, newJobName, cb) {
req.request('post', this.url + '/createItem', this.opts, cb);
};
+/**
+ * Delete an existing job.
+ *
+ * @param {String} jobName: Jenkins job name
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Jenkins.prototype.delete = function (jobName, cb) {
function _success(result, cb) {
@@ -498,6 +544,13 @@ Jenkins.prototype.delete = function (jobName, cb) {
req.request('post', this.url + '/job/' + jobName + '/doDelete', this.opts, cb);
};
+/**
+ * Fetch configuration file (config.xml) of a job.
+ * Result will be written to stdout.
+ *
+ * @param {String} jobName: Jenkins job name
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Jenkins.prototype.config = function (jobName, cb) {
function _success(result, cb) {

0 comments on commit 4f7eee3

Please sign in to comment.