What is ci-info?
The ci-info npm package provides information about the Continuous Integration (CI) environment that your code is running in. It can detect if the current environment is a CI server and provide details about which one it is. This is useful for adjusting the behavior of your application or scripts based on whether they are being run in a CI environment or not.
What are ci-info's main functionalities?
Detecting CI environment
This feature allows you to check if your code is running in a CI environment. The property 'isCI' will be true if it is, or false otherwise.
const ci = require('ci-info');
if (ci.isCI) {
console.log('The code is running in a CI environment.');
} else {
console.log('This is not a CI environment.');
}
Identifying specific CI service
This feature allows you to check for specific CI services. Each supported CI service has a corresponding property that will be true if the code is running on that service.
const ci = require('ci-info');
if (ci.TRAVIS) {
console.log('The code is running on Travis CI.');
}
Getting CI service name
This feature allows you to retrieve the name of the CI service that the code is running on, if it is running in a CI environment.
const ci = require('ci-info');
if (ci.isCI) {
console.log(`The CI service name is ${ci.name}`);
}
Other packages similar to ci-info
is-ci
Similar to ci-info, is-ci is a simple package that allows you to detect if your code is running in a CI environment. However, it does not provide detailed information about which CI service is being used.
env-ci
env-ci is another package that provides information about the CI environment. It offers similar functionality to ci-info, but also includes additional metadata such as branch name, build number, and commit information.
ci-info
Get details about the current Continuous Integration environment.
Please open an
issue
if your CI server isn't properly detected :)
Installation
npm install ci-info --save
Usage
var ci = require('ci-info')
if (ci.isCI) {
console.log('The name of the CI server is:', ci.name)
} else {
console.log('This program is not running on a CI server')
}
Supported CI tools
Officially supported CI servers:
API
ci.name
A string. Will contain the name of the CI server the code is running on.
If not CI server is detected, it will be null
.
Don't depend on the value of this string not to change for a specific
vendor. If you find your self writing ci.name === 'Travis CI'
, you
most likely want to use ci.TRAVIS
instead.
ci.isCI
A boolean. Will be true
if the code is running on a CI server.
Otherwise false
.
Some CI servers not listed here might still trigger the ci.isCI
boolean to be set to true
if they use certain vendor neutral
environment variables. In those cases ci.name
will be null
and no
vendor specific boolean will be set to true
.
ci.<VENDOR-CONSTANT>
The following vendor specific boolean constants are exposed. A constant
will be true
if the code is determined to run on the given CI server.
Otherwise false
.
ci.APPVEYOR
ci.BAMBOO
ci.BITBUCKET
ci.BUILDKITE
ci.CIRCLE
ci.CODEBUILD
ci.CODESHIP
ci.DRONE
ci.GITLAB
ci.GOCD
ci.HUDSON
ci.JENKINS
ci.MAGNUM
ci.SOLANO
ci.SEMAPHORE
ci.STRIDER
ci.TASKCLUSTER
ci.TEAMCITY
ci.TFS
(Team Foundation Server)ci.TRAVIS
Deprecated vendor constants that will be removed in the next major
release:
ci.TDDIUM
(Solano CI) This have been renamed ci.SOLANO
License
MIT