[d24f17c] | 1 | # ci-info
|
---|
| 2 |
|
---|
| 3 | Get details about the current Continuous Integration environment.
|
---|
| 4 |
|
---|
| 5 | Please [open an
|
---|
| 6 | issue](https://github.com/watson/ci-info/issues/new?template=ci-server-not-detected.md)
|
---|
| 7 | if your CI server isn't properly detected :)
|
---|
| 8 |
|
---|
| 9 | [](https://www.npmjs.com/package/ci-info)
|
---|
| 10 | [](https://github.com/watson/ci-info/actions)
|
---|
| 11 | [](https://github.com/feross/standard)
|
---|
| 12 |
|
---|
| 13 | ## Installation
|
---|
| 14 |
|
---|
| 15 | ```bash
|
---|
| 16 | npm install ci-info --save
|
---|
| 17 | ```
|
---|
| 18 |
|
---|
| 19 | ## Usage
|
---|
| 20 |
|
---|
| 21 | ```js
|
---|
| 22 | var ci = require('ci-info')
|
---|
| 23 |
|
---|
| 24 | if (ci.isCI) {
|
---|
| 25 | console.log('The name of the CI server is:', ci.name)
|
---|
| 26 | } else {
|
---|
| 27 | console.log('This program is not running on a CI server')
|
---|
| 28 | }
|
---|
| 29 | ```
|
---|
| 30 |
|
---|
| 31 | ## Supported CI tools
|
---|
| 32 |
|
---|
| 33 | Officially supported CI servers:
|
---|
| 34 |
|
---|
| 35 | | Name | Constant | isPR |
|
---|
| 36 | | ------------------------------------------------------------------------------- | ----------------------- | ---- |
|
---|
| 37 | | [AWS CodeBuild](https://aws.amazon.com/codebuild/) | `ci.CODEBUILD` | 🚫 |
|
---|
| 38 | | [AppVeyor](http://www.appveyor.com) | `ci.APPVEYOR` | ✅ |
|
---|
| 39 | | [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) | `ci.AZURE_PIPELINES` | ✅ |
|
---|
| 40 | | [Appcircle](https://appcircle.io/) | `ci.APPCIRCLE` | 🚫 |
|
---|
| 41 | | [Bamboo](https://www.atlassian.com/software/bamboo) by Atlassian | `ci.BAMBOO` | 🚫 |
|
---|
| 42 | | [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) | `ci.BITBUCKET` | ✅ |
|
---|
| 43 | | [Bitrise](https://www.bitrise.io/) | `ci.BITRISE` | ✅ |
|
---|
| 44 | | [Buddy](https://buddy.works/) | `ci.BUDDY` | ✅ |
|
---|
| 45 | | [Buildkite](https://buildkite.com) | `ci.BUILDKITE` | ✅ |
|
---|
| 46 | | [CircleCI](http://circleci.com) | `ci.CIRCLE` | ✅ |
|
---|
| 47 | | [Cirrus CI](https://cirrus-ci.org) | `ci.CIRRUS` | ✅ |
|
---|
| 48 | | [Codefresh](https://codefresh.io/) | `ci.CODEFRESH` | ✅ |
|
---|
| 49 | | [Codeship](https://codeship.com) | `ci.CODESHIP` | 🚫 |
|
---|
| 50 | | [Drone](https://drone.io) | `ci.DRONE` | ✅ |
|
---|
| 51 | | [dsari](https://github.com/rfinnie/dsari) | `ci.DSARI` | 🚫 |
|
---|
| 52 | | [Expo Application Services](https://expo.dev/eas) | `ci.EAS` | 🚫 |
|
---|
| 53 | | [Gerrit CI](https://www.gerritcodereview.com) | `ci.GERRIT` | 🚫 |
|
---|
| 54 | | [GitHub Actions](https://github.com/features/actions/) | `ci.GITHUB_ACTIONS` | ✅ |
|
---|
| 55 | | [GitLab CI](https://about.gitlab.com/gitlab-ci/) | `ci.GITLAB` | ✅ |
|
---|
| 56 | | [GoCD](https://www.go.cd/) | `ci.GOCD` | 🚫 |
|
---|
| 57 | | [Google Cloud Build](https://cloud.google.com/build) | `ci.GOOGLE_CLOUD_BUILD` | 🚫 |
|
---|
| 58 | | [Harness CI](https://www.harness.io/products/continuous-integration) | `ci.HARNESS` | 🚫 |
|
---|
| 59 | | [Heroku](https://www.heroku.com) | `ci.HEROKU` | 🚫 |
|
---|
| 60 | | [Hudson](http://hudson-ci.org) | `ci.HUDSON` | 🚫 |
|
---|
| 61 | | [Jenkins CI](https://jenkins-ci.org) | `ci.JENKINS` | ✅ |
|
---|
| 62 | | [LayerCI](https://layerci.com/) | `ci.LAYERCI` | ✅ |
|
---|
| 63 | | [Magnum CI](https://magnum-ci.com) | `ci.MAGNUM` | 🚫 |
|
---|
| 64 | | [Netlify CI](https://www.netlify.com/) | `ci.NETLIFY` | ✅ |
|
---|
| 65 | | [Nevercode](http://nevercode.io/) | `ci.NEVERCODE` | ✅ |
|
---|
| 66 | | [ReleaseHub](https://releasehub.com/) | `ci.RELEASEHUB` | 🚫 |
|
---|
| 67 | | [Render](https://render.com/) | `ci.RENDER` | ✅ |
|
---|
| 68 | | [Sail CI](https://sail.ci/) | `ci.SAIL` | ✅ |
|
---|
| 69 | | [Screwdriver](https://screwdriver.cd/) | `ci.SCREWDRIVER` | ✅ |
|
---|
| 70 | | [Semaphore](https://semaphoreci.com) | `ci.SEMAPHORE` | ✅ |
|
---|
| 71 | | [Shippable](https://www.shippable.com/) | `ci.SHIPPABLE` | ✅ |
|
---|
| 72 | | [Solano CI](https://www.solanolabs.com/) | `ci.SOLANO` | ✅ |
|
---|
| 73 | | [Sourcehut](https://sourcehut.org/) | `ci.SOURCEHUT` | 🚫 |
|
---|
| 74 | | [Strider CD](https://strider-cd.github.io/) | `ci.STRIDER` | 🚫 |
|
---|
| 75 | | [TaskCluster](http://docs.taskcluster.net) | `ci.TASKCLUSTER` | 🚫 |
|
---|
| 76 | | [TeamCity](https://www.jetbrains.com/teamcity/) by JetBrains | `ci.TEAMCITY` | 🚫 |
|
---|
| 77 | | [Travis CI](http://travis-ci.org) | `ci.TRAVIS` | ✅ |
|
---|
| 78 | | [Vercel](https://vercel.com/) | `ci.VERCEL` | ✅ |
|
---|
| 79 | | [Visual Studio App Center](https://appcenter.ms/) | `ci.APPCENTER` | 🚫 |
|
---|
| 80 | | [Woodpecker](https://woodpecker-ci.org/) | `ci.WOODPECKER` | ✅ |
|
---|
| 81 |
|
---|
| 82 | ## API
|
---|
| 83 |
|
---|
| 84 | ### `ci.name`
|
---|
| 85 |
|
---|
| 86 | Returns a string containing name of the CI server the code is running on.
|
---|
| 87 | If CI server is not detected, it returns `null`.
|
---|
| 88 |
|
---|
| 89 | Don't depend on the value of this string not to change for a specific
|
---|
| 90 | vendor. If you find your self writing `ci.name === 'Travis CI'`, you
|
---|
| 91 | most likely want to use `ci.TRAVIS` instead.
|
---|
| 92 |
|
---|
| 93 | ### `ci.isCI`
|
---|
| 94 |
|
---|
| 95 | Returns a boolean. Will be `true` if the code is running on a CI server,
|
---|
| 96 | otherwise `false`.
|
---|
| 97 |
|
---|
| 98 | Some CI servers not listed here might still trigger the `ci.isCI`
|
---|
| 99 | boolean to be set to `true` if they use certain vendor neutral
|
---|
| 100 | environment variables. In those cases `ci.name` will be `null` and no
|
---|
| 101 | vendor specific boolean will be set to `true`.
|
---|
| 102 |
|
---|
| 103 | ### `ci.isPR`
|
---|
| 104 |
|
---|
| 105 | Returns a boolean if PR detection is supported for the current CI server. Will
|
---|
| 106 | be `true` if a PR is being tested, otherwise `false`. If PR detection is
|
---|
| 107 | not supported for the current CI server, the value will be `null`.
|
---|
| 108 |
|
---|
| 109 | ### `ci.<VENDOR-CONSTANT>`
|
---|
| 110 |
|
---|
| 111 | A vendor specific boolean constant is exposed for each support CI
|
---|
| 112 | vendor. A constant will be `true` if the code is determined to run on
|
---|
| 113 | the given CI server, otherwise `false`.
|
---|
| 114 |
|
---|
| 115 | Examples of vendor constants are `ci.TRAVIS` or `ci.APPVEYOR`. For a
|
---|
| 116 | complete list, see the support table above.
|
---|
| 117 |
|
---|
| 118 | Deprecated vendor constants that will be removed in the next major
|
---|
| 119 | release:
|
---|
| 120 |
|
---|
| 121 | - `ci.TDDIUM` (Solano CI) This have been renamed `ci.SOLANO`
|
---|
| 122 |
|
---|
| 123 | ## Ports
|
---|
| 124 |
|
---|
| 125 | ci-info has been ported to the following languages
|
---|
| 126 |
|
---|
| 127 | | Language | Repository |
|
---|
| 128 | |----------|------------|
|
---|
| 129 | | Go | https://github.com/hofstadter-io/cinful |
|
---|
| 130 | | Rust | https://github.com/sagiegurari/ci_info |
|
---|
| 131 | | Kotlin | https://github.com/cloudflightio/ci-info |
|
---|
| 132 |
|
---|
| 133 | ## License
|
---|
| 134 |
|
---|
| 135 | [MIT](LICENSE)
|
---|