Check if the process is running in a Continuous Integration (CI) environment
npm install is-in-ci> Check if the process is running in a Continuous Integration (CI) environment
``sh`
npm install is-in-ci
`js
import isInCi from 'is-in-ci';
if (isInCi) {
console.log('Running in a CI environment');
}
`
It looks for these environment variables: CI and CONTINUOUS_INTEGRATION.
`sh`
is-in-ci && echo 'Running in a CI environment'
Exits with code 0 in CI environments and 1 otherwise.
Request the CI service to include the CI environment variable. Most already do.
The is-ci package attempts to detect every CI service, which is unsustainable. It also has a higher risk of false-positives. For example, it detects the environment variable RUN_ID` as CI-specific, although other services could use it. Constant updates for new CIs create version fragmentation, resulting in inconsistent behavior across dependent packages. Pushing for CI services to use a standardized CI environment variable is a more robust solution.
- is-inside-container - Check if the process is running inside a container
- is-interactive - Check if stdout or stderr is interactive