Giter Club home page Giter Club logo

ci-detect's Introduction

@npmcli/ci-detect

THIS PACKAGE HAS BEEN DEPRECATED, USE ci-info INSTEAD

Detect what kind of CI environment the program is in

USAGE

const ciDetect = require('@npmcli/ci-detect')
// false if not in CI
// otherwise, a string indicating the CI environment type
const inCI = ciDetect()

CIs Detected

Returns one of the following strings, or false if none match, by looking at the appropriate environment variables.

  • Anything that sets the CI_NAME environment variable will return the value as the result. (This is how CodeShip is detected.)
  • 'aws-codebuild' AWS CodeBuild
  • 'azure-pipelines' Azure Pipelines
  • 'bamboo' Bamboo
  • 'bitbucket-pipelines' Bitbucket Pipelines
  • 'bitrise' Bitrise
  • 'buddy' Buddy
  • 'builder' Google Cloud Builder - This one is a bit weird. It doesn't really set anything that can be reliably detected except BUILDER_OUTPUT, so it can get false positives pretty easily.
  • 'buildkite' Buildkite
  • 'circleci' Circle-CI
  • 'cirrus' Cirrus CI
  • 'codeship' CodeShip
  • 'custom' anything else that sets CI environment variable to either '1' or 'true'.
  • 'drone' Drone
  • 'dsari' dsari CI
  • 'gerrit' Gerrit
  • 'github-actions' GitHub Actions
  • 'gitlab' GitLab
  • 'gocd' GoCD
  • 'heroku' Heroku
  • 'hudson' Hudson CI
  • 'jenkins' Jenkins
  • 'magnum' Magnum CI
  • 'netlify' Netlify
  • 'nevercode' Nevercode
  • 'now' Zeit.co's Now service, but not GitHub/BitBucket/GitLab
  • 'now-bitbucket' Zeit.co's Now for BitBucket deployment service
  • 'now-github' Zeit.co's Now for GitHub deployment service
  • 'now-gitlab' Zeit.co's Now for GitLab deployment service
  • 'render' Render CI
  • 'sail' Sail CI
  • 'screwdriver' Screwdriver CI
  • 'semaphore' Semaphore
  • 'shippable' Shippable
  • 'strider' Strider CI
  • 'taskcluster' Mozilla Taskcluster
  • 'tddium' TDDium
  • 'teamcity' TeamCity
  • 'travis-ci' Travis-CI - A few other CI systems set TRAVIS=1 in the environment, because devs use that to indicate "test mode", so this one can get some false positives, and is tested later in the process to minimize this effect.
  • 'vercel' Vercel
  • 'vercel-bitbucket' Vercel Bitbucket
  • 'vercel-github' Vercel GitHub
  • 'vercel-gitlab' Vercel Gitlab
  • 'wercker' Oracle Wercker
  • 'woodpecker' Woodpecker CI

Caveats

Since any program can set or unset whatever environment variables they want, this is not 100% reliable.

Also, if your program does different behavior in CI/test/deployment than other places, then there's a good chance that you're doing something wrong!

But, for little niceties like setting colors or other output parameters, or logging and that sort of non-essential thing, this module provides a way to tweak without checking a bunch of things in a bunch of places. Mostly, it's a single place to keep a note of what CI system sets which environment variable.

ci-detect's People

Contributors

6543 avatar bganicky avatar dependabot[bot] avatar github-actions[bot] avatar isaacs avatar kommendorkapten avatar kuldeepkeshwar avatar lukekarrys avatar nlf avatar snyamathi avatar sukkaw avatar ulrichb avatar wraithgar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ci-detect's Issues

[BUG] False negatives in Jenkins CI

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Right now, the Jenkins Pipeline detection solely relies on the existence of JENKINS_URL variable. Per the Jenkins docs:

(NOTE: only available if Jenkins URL set in "System Configuration")

For users that don't configure the Jenkins URL for their CI pipeline, this package returns a false negative.

Expected Behavior

This package should always return true for Jenkins CI, so I propose adding a check for the BUILD_ID variable as an additional check for Jenkins since that value should always be there in Jenkins CI. This is what ci-info does: https://github.com/watson/ci-info/blob/master/vendors.json#L135

Steps To Reproduce

No response

Environment

  • npm: 8.19.3
  • Node: 16.14.0
  • OS: macOS
  • platform: MacBook Pro

Reporting a vulnerability

Hello!

I hope you are doing well!

We are a security research team. Our tool automatically detected a vulnerability in this repository. We want to disclose it responsibly. GitHub has a feature called Private vulnerability reporting, which enables security research to privately disclose a vulnerability. Unfortunately, it is not enabled for this repository.

Can you enable it, so that we can report it?

Thanks in advance!

PS: you can read about how to enable private vulnerability reporting here: https://docs.github.com/en/code-security/security-advisories/repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.