Git Product home page Git Product logo

ci-info's Introduction

ci-info

Get details about the current Continuous Integration environment.

Please open an issue if your CI server isn't properly detected :)

npm Tests js-standard-style

Installation

npm install ci-info --save

Usage

var ci = require('ci-info')

if (ci.isCI) {
  console.log('The name of the CI server is:', ci.name)
} else {
  console.log('This program is not running on a CI server')
}

Supported CI tools

Officially supported CI servers:

Name Constant isPR
Agola CI ci.AGOLA โœ…
Appcircle ci.APPCIRCLE ๐Ÿšซ
AppVeyor ci.APPVEYOR โœ…
AWS CodeBuild ci.CODEBUILD ๐Ÿšซ
Azure Pipelines ci.AZURE_PIPELINES โœ…
Bamboo by Atlassian ci.BAMBOO ๐Ÿšซ
Bitbucket Pipelines ci.BITBUCKET โœ…
Bitrise ci.BITRISE โœ…
Buddy ci.BUDDY โœ…
Buildkite ci.BUILDKITE โœ…
CircleCI ci.CIRCLE โœ…
Cirrus CI ci.CIRRUS โœ…
Codefresh ci.CODEFRESH โœ…
Codeship ci.CODESHIP ๐Ÿšซ
Drone ci.DRONE โœ…
dsari ci.DSARI ๐Ÿšซ
Earthly CI ci.EARTHLY ๐Ÿšซ
Expo Application Services ci.EAS ๐Ÿšซ
Gerrit CI ci.GERRIT ๐Ÿšซ
GitHub Actions ci.GITHUB_ACTIONS โœ…
GitLab CI ci.GITLAB โœ…
Gitea Actions ci.GITEA_ACTIONS ๐Ÿšซ
GoCD ci.GOCD ๐Ÿšซ
Google Cloud Build ci.GOOGLE_CLOUD_BUILD ๐Ÿšซ
Harness CI ci.HARNESS ๐Ÿšซ
Heroku ci.HEROKU ๐Ÿšซ
Hudson ci.HUDSON ๐Ÿšซ
Jenkins CI ci.JENKINS โœ…
LayerCI ci.LAYERCI โœ…
Magnum CI ci.MAGNUM ๐Ÿšซ
Netlify CI ci.NETLIFY โœ…
Nevercode ci.NEVERCODE โœ…
Prow ci.PROW ๐Ÿšซ
ReleaseHub ci.RELEASEHUB ๐Ÿšซ
Render ci.RENDER โœ…
Sail CI ci.SAIL โœ…
Screwdriver ci.SCREWDRIVER โœ…
Semaphore ci.SEMAPHORE โœ…
Sourcehut ci.SOURCEHUT ๐Ÿšซ
Strider CD ci.STRIDER ๐Ÿšซ
TaskCluster ci.TASKCLUSTER ๐Ÿšซ
TeamCity by JetBrains ci.TEAMCITY ๐Ÿšซ
Travis CI ci.TRAVIS โœ…
Vela ci.VELA โœ…
Vercel ci.VERCEL โœ…
Visual Studio App Center ci.APPCENTER ๐Ÿšซ
Woodpecker ci.WOODPECKER โœ…

API

ci.name

Returns a string containing name of the CI server the code is running on. If CI server is not detected, it returns null.

Don't depend on the value of this string not to change for a specific vendor. If you find your self writing ci.name === 'Travis CI', you most likely want to use ci.TRAVIS instead.

ci.isCI

Returns a boolean. Will be true if the code is running on a CI server, otherwise false.

Some CI servers not listed here might still trigger the ci.isCI boolean to be set to true if they use certain vendor neutral environment variables. In those cases ci.name will be null and no vendor specific boolean will be set to true.

ci.isPR

Returns a boolean if PR detection is supported for the current CI server. Will be true if a PR is being tested, otherwise false. If PR detection is not supported for the current CI server, the value will be null.

ci.<VENDOR-CONSTANT>

A vendor specific boolean constant is exposed for each support CI vendor. A constant will be true if the code is determined to run on the given CI server, otherwise false.

Examples of vendor constants are ci.TRAVIS or ci.APPVEYOR. For a complete list, see the support table above.

Ports

ci-info has been ported to the following languages

Language Repository
Go https://github.com/hofstadter-io/cinful
Rust https://github.com/sagiegurari/ci_info
Kotlin https://github.com/cloudflightio/ci-info

License

MIT

ci-info's People

Contributors

6543 avatar alexdebrie avatar anurag avatar bdellegrazie avatar bragle avatar brentvatne avatar ehmicky avatar fkorotkov avatar frosas avatar gkampitakis avatar gucong3000 avatar jessehouwing avatar klu2 avatar lucleray avatar mathieudutour avatar paescuj avatar rfinnie avatar sagiegurari avatar sassninja avatar sibiraj-s avatar styfle avatar varshachahal avatar verdverm avatar vtbassmatt avatar watson avatar wraithgar avatar zachjw34 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  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  avatar  avatar  avatar

ci-info's Issues

Add a `CHANGELOG`

Would it be possible to add a CHANGELOG so it's easy to keep up-to-date with new releases without checking the individual commits?

Thanks for this project!

Add support for GitHub Actions

Details:

Environment variables

Environment variables example
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=fb1d0264fdb4
GITHUB_ACTION=Env
GITHUB_ACTOR=j-f1
GITHUB_EVENT_NAME=push
GITHUB_EVENT_PATH=/github/workflow/event.json
GITHUB_REPOSITORY=j-f1/eslint-docs
GITHUB_SHA=50141211ee907a2f592f03d99caf45c131fb6782
GITHUB_WORKFLOW=Run tests
GITHUB_WORKSPACE=/github/workspace
HOME=/github/home
GITHUB_REF=refs/heads/tmp

Additional context
It would be nice to add support for this before it gets out of beta.

Maintenance: Do you need help maintaining this project?

There are several issues that have been open and idle for months. Do you need help maintaining the project?

I'd like to volunteer my services of reviewing and merging PRs among other things. I'm sure there are others in the community that would be willing to share the load as well.

Add Xcode Server & Xcode Cloud

Gitlab isPR not working

The docs say isPR is supported for Gitlab CI which is not correct since I've run into exactly this issue.

The problem is the vendors.json file does not contain any pr key for gitlab.

This can be easily fixed by adding it.
I'll create a PR.

๐Ÿ‘‹ Sibiraj

Hi @sibiraj-s

I've noticed that you've helped out a lot here and in is-ci. Thank you, I really appreciate your time and energy.

As you might have seen in your e-mails I've therefore added you as a maintainer to both projects - which I hope you don't mind ๐Ÿ˜„

Azure Pipelines is not detected

Details:

Environment variables

Environment variables example
// Add a list of actual environment variables available to the build here
// Please keep the blank line above and below the code block
// WARNING: Be careful not to include any private or otherwise sensitive information

Additional context
Disclosure: I'm a product manager on Azure Pipelines.

Platform.sh support

Details:

Environment variables
Vars are listed at https://docs.platform.sh/development/variables.html#use-platformsh-provided-variables

I believe PLATFORM_OUTPUT_DIR might be the variable to check for whether to consider the environment a CI. P.sh reuses the same containers, and that is the only variable that is available in builds only (and not afterwards at runtime).

That said, PLATFORM_TREE_ID is the appropriate variable for a build ID.

Jenkins x

Details:

Environment variables

Environment variables example
JOB_SPEC=type:postsubmit
PULL_NUMBER=
SHLVL=1
PIPELINE_KIND=release
REPO_OWNER=projectman
HOME=/tekton/home
PULL_REFS=master
DOCKER_REGISTRY_ORG=projectman
REPO_URL=https://gitlab.com/projectman/projectman.git
HOOK_PORT_80_TCP_ADDR=10.233.41.116
APP_NAME=projectman
JX_CHART_REPOSITORY=http://bucketrepo/bucketrepo/charts/
VERSION=0.0.22
REPO_NAME=projectman
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
BUILD_ID=1608568154259
PULL_PULL_SHA=
MINK_AS=tekton-bot
PULL_PULL_REF=
JOB_TYPE=postsubmit
BUILD_NUMBER=3
DOCKERFILE_PATH=Dockerfile
PULL_BASE_REF=master
JOB_NAME=release
JX3_HOME=/home/.jx3

Add support for Ionic Appflow

Details:

Environment variables

Environment variables example
// Add a list of actual environment variables available to the build here
// Please keep the blank line above and below the code block
// WARNING: Be careful not to include any private or otherwise sensitive information

Additional context
Appflow is a continuous integration (CI) and continuous deployment (CD) platform for Ionic development teams. Appflow helps development teams continuously build and ship their Cordova, Capacitor, and React Native apps.

Detect PR for AWS CodeBuild

AWS CodeBuild now has an environment variable that works with GitHub and BitBucket when setup using WebHooks which can be used to detect PR builds.

CODEBUILD_WEBHOOK_EVENT with values PULL_REQUEST_CREATED, PULL_REQUEST_UPDATED, and PULL_REQUEST_REOPENED

Add support for Sourcehut CI

Details:

Environment variables
JOB_ID, JOB_URL

Test Build Manifest
image: alpine/edge
packages:
  - git
  - nodejs
  - npm
tasks:
  - setup: |
      npx is-ci && echo "This is a CI server" || echo "This is not a CI server"
      echo $JOB_ID
      echo $JOB_URL
      printenv
Output of Test Manifest
npx: installed 2 in 1.752s
+ echo 'This is not a CI server'
This is not a CI server
+ echo 359361
359361
+ echo https://builds.sr.ht/~royston/job/359361
https://builds.sr.ht/~royston/job/359361
+ printenv
SHELL=/bin/sh
PWD=/home/build
LOGNAME=build
JOB_URL=https://builds.sr.ht/~royston/job/359361
HOME=/home/build
SSH_CONNECTION=172.17.0.1 55330 10.0.2.15 22
TERM=xterm-256color
USER=build
SHLVL=2
SSH_CLIENT=172.17.0.1 55330 22
PATH=/bin:/usr/bin:/sbin:/usr/sbin
JOB_ID=359361
MAIL=/var/mail/build
SSH_TTY=/dev/pts/0
_=/bin/printenv

Additional context
env.JOB_URL.startsWith('https://builds.sr.ht/') seems to be the pattern

Parametrable env

Just find this plugin and would like to use it but I'm stuck with its current design.

My use case is that I need to pass in an env object instead of just process.env here https://github.com/nfroidure/metapak/blob/master/src/metapak.js#L88

Basically what I need is a isCi(env = process.env) function and something like a getInfo(env = process.env) one for the above code that is heavier.

It would also have the nice side effect to be able to to lazy compute the data provided by this plugin and only compute the informations you need. One can til memoize the function if needed then to avoid multiple runs.

The tests would probably be much simpler too.

If you agree we that, let me know, I can do the PR. It would require a major version bump though.

exported isCI ignores env variable set to false

In the official docker image node:14-buster the env variable CI is set to true:

CI=true

I use this container for developing purposes (as base of a vscode devcontainer) and in order to install husky it was necessary to set the env variable CI to false:

CI=false

Unfortunately isCI returns true in this case, because env.CI has the value "false" (string) and the current used implementation converts this value to true:

// returns true
!!("false")
exports.isCI = !!(
  env.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari
  env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
  env.BUILD_NUMBER || // Jenkins, TeamCity
  env.RUN_ID || // TaskCluster, dsari
  exports.name ||
  false
)

EAS variable is not exposed

Details:

Additional context
The EAS variable (ci.EAS) does not appear to be visible at all (not exported) as a constant.

Add Concourse to the list of detected servers

Details:

Environment variables

Environment variables example
// Add a list of actual environment variables available to the build here
// Please keep the blank line above and below the code block
// WARNING: Be careful not to include any private or otherwise sensitive information

Additional context
Concourse runs a series of steps each in its own docker container. Environment variables are
passed into each container. The ones I work with are the ones I passed unique to my job and environment. I have not yet had to deal with any global environment variables that would identify it as Concourse, although Im sure there must be some.

publish a new version

Can we publish a new version? We're using GitHub Actions but it does not get detected. After making sure that we got the latest version installed we figured that the vendors file of the latest published version is missing some new vendors that have been added last year.

So yeah, can we publish a new version? โค๏ธ

Add Releasehub?

Hi,

We have a customer who uses is-ci to tweak their behavior when building, and they've noticed that we're not supported (which is not a surprise, we're a small SaaS company). I had a look at your code and it looks like you just check for env vars, is there any chance you could add a check for:

  • RELEASE_COMMIT_SHA

I know we have kind of a generic name, but I think this should be a pretty unique identifier.

isCI is true on local?

Details:

  • Ci name: None
  • Website: N/A
  • Default env variables: N/A

Environment variables

Environment variables
{ PATH: '/Users/mvarrieur/.asdf/installs/nodejs/8.10.0/bin:/Users/mvarrieur/.asdf/installs/nodejs/8.10.0/.npm/bin::/Users/mvarrieur/.asdf/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin',
  TERM_PROGRAM: 'iTerm.app',
  TERM: 'xterm-256color',
  SHELL: '/usr/local/bin/fish',
  ASDF_DIR: '/Users/mvarrieur/.asdf',
  OMF_CONFIG: '/Users/mvarrieur/.config/omf',
  TMPDIR: '/var/folders/8h/s585mmcs4wd749mvcdg19v380000gn/T/',
  Apple_PubSub_Socket_Render: '/private/tmp/com.apple.launchd.2NKGHgl0UD/Render',
  TERM_PROGRAM_VERSION: '3.2.9',
  TERM_SESSION_ID: 'w0t0p0:C01B3F3B-99E9-4B35-8204-6B6DF61DB471',
  USER: 'mvarrieur',
  COMMAND_MODE: 'unix2003',
  SSH_AUTH_SOCK: '/private/tmp/com.apple.launchd.gTgQAeYs7A/Listeners',
  __CF_USER_TEXT_ENCODING: '0x1F5:0x0:0x0',
  NPM_CONFIG_PREFIX: '/Users/mvarrieur/.asdf/installs/nodejs/8.10.0/.npm',
  PWD: '/Users/mvarrieur/Projects/project',
  LANG: 'en_US.UTF-8',
  ITERM_PROFILE: 'Default',
  XPC_FLAGS: '0x0',
  XPC_SERVICE_NAME: '0',
  SHLVL: '2',
  HOME: '/Users/mvarrieur',
  COLORFGBG: '15;0',
  OMF_PATH: '/Users/mvarrieur/.local/share/omf',
  ITERM_SESSION_ID: 'w0t0p0:C01B3F3B-99E9-4B35-8204-6B6DF61DB471',
  LOGNAME: 'mvarrieur',
  BUILD_NUMBER: '4',
  SECURITYSESSIONID: '186aa',
  COLORTERM: 'truecolor' }

Additional context
I'm expecting isCI to be false on my local machine, but it's returning true.

Here is the output from node:

> var ciInfo = require('ci-info');
> ciInfo
{ name: null,
  isPR: null,
  APPVEYOR: false,
  AZURE_PIPELINES: false,
  BAMBOO: false,
  BITBUCKET: false,
  BITRISE: false,
  BUDDY: false,
  BUILDKITE: false,
  CIRCLE: false,
  CIRRUS: false,
  CODEBUILD: false,
  CODESHIP: false,
  DRONE: false,
  DSARI: false,
  GITLAB: false,
  GOCD: false,
  HUDSON: false,
  JENKINS: false,
  MAGNUM: false,
  NETLIFY: false,
  SAIL: false,
  SEMAPHORE: false,
  SHIPPABLE: false,
  SOLANO: false,
  STRIDER: false,
  TASKCLUSTER: false,
  TEAMCITY: false,
  TRAVIS: false,
  isCI: true }

[Question] Can I port this library to Golang

Hello ๐Ÿ‘‹, came across this lovely library and I would like to use it in a Golang project of mine. Unfortunately, I have not seen something similar in Golang. So I was wondering If it's fine with you to use it to replicate the same functionality?

Sorry for opening an issue with this question. Thanks for your time ๐Ÿ˜„

Detect Render CI

Details:

Environment variables

Environment variables example
CI="true"
RENDER="true"
IS_PULL_REQUEST="true" (or "false")

Additional context
Opening this issue before submitting a PR to add detection. Disclosure: I work at Render.

1.5.0 breaks Jest runs

Details:

  • Ci name: local environment
  • Default env variables: none

Additional context

I've noticed it today so just after upgrading to 1.5.0, it looks jest-resolve has a problem with vendors.json - for some reason it cannot load it properly:

  โ— Test suite failed to run

    Cannot find module './vendors' from 'index.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:221:17)
      at Object.<anonymous> (node_modules/is-ci/node_modules/ci-info/index.js:3:15)

It might be more a jest-resolve problem, but it doesn't change the fact that all my builds (jest tests) are broken now.

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.