https://github.com/holyshared/ci-detector
Detect the CI server environment
https://github.com/holyshared/ci-detector
Last synced: about 1 month ago
JSON representation
Detect the CI server environment
- Host: GitHub
- URL: https://github.com/holyshared/ci-detector
- Owner: holyshared
- License: mit
- Created: 2015-01-20T01:01:47.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-09-03T00:37:51.000Z (almost 11 years ago)
- Last Synced: 2025-02-17T13:45:16.536Z (over 1 year ago)
- Language: CoffeeScript
- Homepage:
- Size: 410 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ci-detector
================================
[](http://badge.fury.io/js/ci-detector)
[](https://travis-ci.org/holyshared/ci-detector)
[](https://codeclimate.com/github/holyshared/ci-detector)
[](https://codeclimate.com/github/holyshared/ci-detector)
[](https://gemnasium.com/holyshared/ci-detector)
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.
```javascript
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.
```javascript
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.
```javascript
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
-----------------------------------------
* [Travis CI](https://travis-ci.org/)
* [Drone.IO](https://drone.io/)
* [CircleCI](https://circleci.com/)
* [Codeship](https://codeship.com)
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