lib/jenkins.js
function Jenkins(opts) {
  if (!(this instanceof Jenkins)) {
    return new Jenkins(opts);
  }

  if (typeof opts === 'string') {
    opts = { baseUrl: opts };
  } else {
    opts = opts || {};
  }

  opts = Object.assign({}, opts);

  if (!opts.baseUrl) {
    if (opts.url) {
      opts.baseUrl = opts.url;
      delete opts.url;
    } else {
      throw new Error('baseUrl required');
    }
  }

  if (!opts.headers) {
    opts.headers = {};
  }
  if (!opts.headers.referer) {
    opts.headers.referer = opts.baseUrl + '/';
  }

  if (opts.request) {
    throw new Error('request not longer supported');
  }

  opts.name = 'jenkins';

  if (typeof opts.crumbIssuer === 'function') {
    this._crumbIssuer = opts.crumbIssuer;
    delete opts.crumbIssuer;
  } else if (opts.crumbIssuer === true) {
    this._crumbIssuer = utils.crumbIssuer;
  }

  if (opts.formData) {
    if (typeof opts.formData !== 'function' || opts.formData.name !== 'FormData') {
      throw new Error('formData is invalid');
    }
    this._formData = opts.formData;
    delete opts.formData;
  }

  papi.Client.call(this, opts);

  this._ext('onCreate', this._onCreate);
  this._ext('onResponse', this._onResponse);

  this.build = new Jenkins.Build(this);
  this.crumbIssuer = new Jenkins.CrumbIssuer(this);
  this.job = new Jenkins.Job(this);
  this.label = new Jenkins.Label(this);
  this.node = new Jenkins.Node(this);
  this.queue = new Jenkins.Queue(this);
  this.view = new Jenkins.View(this);

  try {
    if (opts.promisify) {
      if (typeof opts.promisify === 'function') {
        papi.tools.promisify(this, opts.promisify);
      } else {
        papi.tools.promisify(this);
      }
    }
  } catch (err) {
    err.message = 'promisify: ' + err.message;
    throw err;
  }
}
function Jenkins(opts) {
  if (!(this instanceof Jenkins)) {
    return new Jenkins(opts);
  }

  if (typeof opts === 'string') {
    opts = { baseUrl: opts };
  } else {
    opts = opts || {};
  }

  opts = Object.assign({}, opts);

  if (!opts.baseUrl) {
    if (opts.url) {
      opts.baseUrl = opts.url;
      delete opts.url;
    } else {
      throw new Error('baseUrl required');
    }
  }

  if (!opts.headers) {
    opts.headers = {};
  }
  if (!opts.headers.referer) {
    opts.headers.referer = opts.baseUrl + '/';
  }

  if (opts.request) {
    throw new Error('request not longer supported');
  }

  opts.name = 'jenkins';

  if (typeof opts.crumbIssuer === 'function') {
    this._crumbIssuer = opts.crumbIssuer;
    delete opts.crumbIssuer;
  } else if (opts.crumbIssuer === true) {
    this._crumbIssuer = utils.crumbIssuer;
  }

  if (opts.formData) {
    if (typeof opts.formData !== 'function' || opts.formData.name !== 'FormData') {
      throw new Error('formData is invalid');
    }
    this._formData = opts.formData;
    delete opts.formData;
  }

  papi.Client.call(this, opts);

  this._ext('onCreate', this._onCreate);
  this._ext('onResponse', this._onResponse);

  this.build = new Jenkins.Build(this);
  this.crumbIssuer = new Jenkins.CrumbIssuer(this);
  this.job = new Jenkins.Job(this);
  this.label = new Jenkins.Label(this);
  this.node = new Jenkins.Node(this);
  this.queue = new Jenkins.Queue(this);
  this.view = new Jenkins.View(this);

  try {
    if (opts.promisify) {
      if (typeof opts.promisify === 'function') {
        papi.tools.promisify(this, opts.promisify);
      } else {
        papi.tools.promisify(this);
      }
    }
  } catch (err) {
    err.message = 'promisify: ' + err.message;
    throw err;
  }
}
function Jenkins ( opts ) { if ( ! ( this instanceof Jenkins ) ) { return new Jenkins ( opts ) ; } if ( typeof opts === 'string' ) { opts = { baseUrl : opts } ; } else { opts = opts || { } ; } opts = Object . assign ( { } , opts ) ; if ( ! opts . baseUrl ) { if ( opts . url ) { opts . baseUrl = opts . url ; delete opts . url ; } else { throw new Error ( 'baseUrl required' ) ; } } if ( ! opts . headers ) { opts . headers = { } ; } if ( ! opts . headers . referer ) { opts . headers . referer = opts . baseUrl + '/' ; } if ( opts . request ) { throw new Error ( 'request not longer supported' ) ; } opts . name = 'jenkins' ; if ( typeof opts . crumbIssuer === 'function' ) { this . _crumbIssuer = opts . crumbIssuer ; delete opts . crumbIssuer ; } else if ( opts . crumbIssuer === true ) { this . _crumbIssuer = utils . crumbIssuer ; } if ( opts . formData ) { if ( typeof opts . formData !== 'function' || opts . formData . name !== 'FormData' ) { throw new Error ( 'formData is invalid' ) ; } this . _formData = opts . formData ; delete opts . formData ; } papi . Client . call ( this , opts ) ; this . _ext ( 'onCreate' , this . _onCreate ) ; this . _ext ( 'onResponse' , this . _onResponse ) ; this . build = new Jenkins . Build ( this ) ; this . crumbIssuer = new Jenkins . CrumbIssuer ( this ) ; this . job = new Jenkins . Job ( this ) ; this . label = new Jenkins . Label ( this ) ; this . node = new Jenkins . Node ( this ) ; this . queue = new Jenkins . Queue ( this ) ; this . view = new Jenkins . View ( this ) ; try { if ( opts . promisify ) { if ( typeof opts . promisify === 'function' ) { papi . tools . promisify ( this , opts . promisify ) ; } else { papi . tools . promisify ( this ) ; } } } catch ( err ) { err . message = 'promisify: ' + err . message ; throw err ; } }
Initialize a new `Jenkins` client.
Initialize a new Jenkins client .