ci-detector

0.1.2 • Public • Published

ci-detector

npm version Build Status Test Coverage Code Climate Dependency Status

Usage

If you pass an object of environment variable in the argument, it automatically detects the environment.
You do not need to worry about the difference of environment variables of ci server.

var util = require('util');
var detector = require('ci-detector');
var env = detector.lookup(process.env);
util.log(env.name); //travis-ci
util.log(env.branch); //master
util.log(env.commit); //1d3b5371ef1851caf256773efb9deb9e27875272

Check the environment

You can check the environment as follows.
Supported method isTravisCI, isCircleCI, isDroneIO, isCodeship, isJenkins.

var util = require('util');
var detector = require('ci-detector');
 
console.log(detector.isTravisCI(process.env)); //true
console.log(detector.isCircleCI(process.env)); //false
console.log(detector.isDroneIO(process.env)); //false
console.log(detector.isCodeship(process.env)); //false
console.log(detector.isJenkins(process.env)); //false

Access to environment variables

You can check the environment variable in the has method.
To get the environment variables you can use the get method.

var util = require('util');
var detector = require('ci-detector');
var env = detector.lookup(process.env);
 
if (env.has('CI', 'CIRCLECI')) {
  util.log(env.get('CI')); //true
  util.log(env.get('CIRCLECI')); //true
}

Support ci services

Enviroment properties

  • branch - the branch currently being built
  • commit - the commit hash currently being built
  • buildId - the current build id
  • buildNumber - the current build number
  • buildJobId - the current build job id
  • buildJobNumber - the current build job number

Package Sidebar

Install

npm i ci-detector

Weekly Downloads

3

Version

0.1.2

License

MIT

Last publish

Collaborators

  • holyshared