1.3.1 • Published 5 years ago

jenkins-wait v1.3.1

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

jenkins-wait

Build Status npm version

code style: prettier Conventional Commits semantic-release

A patient library for automating your automation

You should not need this module.

Sometimes you can't control your corporate jenkins configuration, and have no choice but to trigger jobs manually. This library is made for that situation.

It can be installed globally and invoked from the command line, or imported and used as a part of another script. jenkins-wait will trigger a job, and wait for it to start, and finish, exiting with or returning the status of the triggered job.

Installation

use in your project

npm install --save-dev jenkins-wait

or globally

npm install --global jenkins-wait

Options

optionrequireddefaultdescription
jenkins-baseyesBase jenkins url
job-locationyesLocation of the job
usernamenoundefinedusername for basic auth
passwordnoundefinedpassword for basic auth
poll-intervalno1000how long to wait before querying jenkins for build status
use-httpsnotrueuse https protocol in making jenkins requests
silentnofalsesuppress console output
verbosenofalseverbosely log all output, takes precedence over silent
print-consolenofalsePrint console output of the job after it completes
parametersnoundefinedcolon-separated parameters to use for a parameterized build

Command-line

jenkins-wait [options]

or use with npx

npx jenkins-wait [options]

It will exit with 0 when the triggered job returns a status of SUCCESS and a 1 for all other statuses.

API

The library exposes the JenkinsTrigger class

API Examples

Without parameters

const { JenkinsTrigger } = require('jenkins-wait');

const jenkinsJob = new JenkinsTrigger({
  baseJenkins: 'ci.mycompany.com',
  jobLocation: 'topLevel/myProject',
  username: 'itsme',
  password: 'securepassword',
  pollInterval: 1000,
  useHttps: true,
  silent: false
});

jenkinsJob
  .runJob()
  .then(result => {
    //do whatever you want with the result
  })
  .catch(error => {
    // Make sure to handle errors!
  });

With parameters

const { JenkinsTrigger } = require('jenkins-wait');

const jenkinsJob = new JenkinsTrigger({
  baseJenkins: 'ci.mycompany.com',
  jobLocation: 'topLevel/myProject',
  username: 'itsme',
  password: 'securepassword',
  pollInterval: 1000,
  useHttps: true,
  silent: true
});

jenkinsJob
  .runJob({ keyOne: 'valueOne', keyTwo: 'valueTwo' })
  .then(result => {
    // Do whatever you want with the result
  })
  .catch(error => {
    // Make sure to handle errors!
  });

CI Integration

When jenkins-wait is run from a CI environment (TravisCI, CircleCI, Jenkins, etc.) The running seconds count will not be printed to the console. When the CLI is used, it will also be run in verbose mode by default.

Development

Setup

npm install

Run tests

npm test

Build with babel

npm run build

Build in watch mode

Helpful for development

npm run build:watch
1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago