Coder Social home page Coder Social logo

ci-detector's Introduction

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

ci-detector's People

Contributors

holyshared avatar

Stargazers

 avatar  avatar

Watchers

 avatar

ci-detector's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.