Get details of the current CI environment. This library is heavily inspired by https://github.com/watson/ci-info.
Note: this library needs Node.js and a console you can type in commands (PowerShell on Windows, Terminal on macOS and your favorite terminal emulator on every other OS). The minimum required version of Node.js is: 8 - codename "Carbon".
In your console, run the following command:
$ npm install ci-info-next
You can also use yarn
(like we do in this project):
$ yarn add ci-info-next
The library exports the following API:
-
function
detectVendor
: get an array of possible CI vendors based on the defined environment variables;// process.env: TRAVIS='',TRAVIS_PULL_REQUEST='' const {detectVendor} = require('ci-info-next'); console.log(detectVendor()); // Logs: ['TRAVIS']
-
function
isCI
: detect if the current environment is running on a Continuous Integration service;// On your PC const {isCI} = require('ci-info-next'); console.log(isCI()); // Logs: false // On a CI service... console.log(isCI()); // Logs: true
-
function
isPR
: detect if the current environment is running on Pull Request build within a Continuous Integration service;// process.env: TRAVIS='',TRAVIS_PULL_REQUEST='' const {isPR} = require('ci-info-next'); console.log(isPR()); // Logs: true
-
object
vendors
: containing the supported CI services.
Name | Constant | Supports PR detection |
---|---|---|
AppVeyor | APPVEYOR |
Yes |
AWS CodeBuild | AWS_CODEBUILD |
No |
Azure Pipelines | AZURE_PIPELINES |
Yes |
Bamboo | BAMBOO |
No |
Bitbucket Pipelines | BITBUCKET |
Yes |
Bitrise | BITRISE |
Yes |
Buddy | BUDDY |
Yes |
Buildkite | BUILDKITE |
Yes |
CircleCI | CIRCLE |
Yes |
Cirrus CI | CIRRUS |
Yes |
Codeship | CODESHIP |
No |
Drone | DRONE |
Yes |
dsari | DSARI |
No |
GitHub Actions | GITHUB |
Yes |
GitLab CI | GITLAB |
No |
GoCD | GOCD |
No |
Hudson | HUDSON |
No |
Jenkins | JENKINS |
Yes |
Netlify Build | NETLIFY |
Yes |
Nevercode | NEVERCODE |
Yes |
Sail CI | SAIL |
Yes |
Semaphore | SEMAPHORE |
Yes |
Shippable | SHIPPABLE |
Yes |
Strider CD | STRIDER |
No |
TaskCluster | TASKCLUSTER |
No |
TeamCity | TEAMCITY |
No |
Travis CI | TRAVIS |
Yes |
Pretty-printable name of the CI Vendor, for example 'Travis CI'
.
This property is an internal "id" of the CI Vendor. This library enforces an uppercased format, for example 'TRAVIS'
.
This function checks if the specified environment variables match this vendor's required environment variables.
Returns true
if the current environment variables suggest that this vendor could be the one in use.
Throws a TypeError
if the specified envs
argument is not of type 'object'
.
Type: object
Environment variables object that allows you to override the default process environment.
This function checks if the specified environment variables match this vendor's required environment variables for Pull Requests.
Returns true
if the current environment variables suggest that this vendor could be the one in use.
This function returns null
if the vendor does not provide a reliable way to check for a PR environment.
Throws a TypeError
if the specified envs argument is not of type 'object'
.
Type: object
Environment variables object that allows you to override the default process environment.
Returns: CIVendor[]
Tries to detect which vendors match the specified environment and returns an array of the vendors matching the specified environment.
Type: object
Default: process.env
Environment variables object that allows you to override the default process environment.
This function returns whether the specified environment variables suggest a CI environment.
Type: object
Default: process.env
Environment variables object that allows you to override the default process environment.
Returns whether the specified environment variables suggest a PR build in the CI system.
Type: object
Default: process.env
Environment variables object that allows you to override the default process environment.
This object contains all the supported CI vendors, both individually (using the CIVendor[CONSTANT]
property) and collectively (all
property).