ci-info-next
v1.0.0
Published
Get details of the current CI environment. Heavily inspired by https://github.com/watson/ci-info-next
Downloads
3
Readme
ci-info-next
Get details of the current CI environment. This library is heavily inspired by https://github.com/watson/ci-info.
Installation
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
Usage
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.
Supported CI vendors
| 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 |
API
CIVendor
name
Pretty-printable name of the CI Vendor, for example 'Travis CI'
.
constant
This property is an internal "id" of the CI Vendor. This library enforces an uppercased format, for example 'TRAVIS'
.
detectEnvFunction(envs)
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'
.
envs
Type: object
Environment variables object that allows you to override the default process environment.
detectPRFunction(envs)
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'
.
envs
Type: object
Environment variables object that allows you to override the default process environment.
detectVendor(envs?)
Returns: CIVendor[]
Tries to detect which vendors match the specified environment and returns an array of the vendors matching the specified environment.
envs
Type: object
Default: process.env
Environment variables object that allows you to override the default process environment.
isCI(envs?)
This function returns whether the specified environment variables suggest a CI environment.
envs
Type: object
Default: process.env
Environment variables object that allows you to override the default process environment.
isPR(envs?)
Returns whether the specified environment variables suggest a PR build in the CI system.
envs
Type: object
Default: process.env
Environment variables object that allows you to override the default process environment.
vendors
This object contains all the supported CI vendors, both individually (using the CIVendor[CONSTANT]
property) and collectively (all
property).