Detect CI Environment

4.1.0 · active · verified Sun Apr 19

The `is-ci` package provides a minimalist, direct method for determining whether the current process is executing within a Continuous Integration (CI) environment. It exposes a simple boolean value (`true` if running in CI, `false` otherwise), abstracting away the complexities of checking various environment variables across different CI providers. The current stable version is `4.1.0`. The library typically sees updates in conjunction with its underlying dependency, `ci-info`, which is responsible for the core detection logic, leading to an irregular but feature-driven release cadence. Its primary differentiator is its singular focus on providing a simple boolean answer, making it ideal for conditional logic in build scripts, test runners, or deployment pipelines where CI context is crucial. It supports a wide array of CI services by leveraging `ci-info`'s comprehensive detection capabilities.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import and use `is-ci` in both ESM and CJS contexts to conditionally execute code based on CI environment detection.

import isCI from 'is-ci';

console.log(`Checking CI status (ESM):`);
if (isCI) {
  console.log('  This code is running on a CI server.');
} else {
  console.log('  This code is NOT running on a CI server.');
}

// For CommonJS environments:
/*
const isCI_cjs = require('is-ci');
console.log(`\nChecking CI status (CJS):`);
if (isCI_cjs) {
  console.log('  This CJS code is running on a CI server.');
} else {
  console.log('  This CJS code is NOT running on a CI server.');
}
*/

// Example of conditional logic based on CI detection
if (isCI && process.env.NODE_ENV === 'production') {
  console.log('\nRunning production build steps on CI...');
} else if (!isCI && process.env.NODE_ENV === 'development') {
  console.log('\nRunning local development tasks...');
}

view raw JSON →