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 | [![npm](https://img.shields.io/npm/v/ci-info.svg)](https://www.npmjs.com/package/ci-info)
|
10 | [![Build status](https://travis-ci.org/watson/ci-info.svg?branch=master)](https://travis-ci.org/watson/ci-info)
|
11 | [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](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 | | [Bamboo](https://www.atlassian.com/software/bamboo) by Atlassian | `ci.BAMBOO` | 🚫 |
|
41 | | [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) | `ci.BITBUCKET` | ✅ |
|
42 | | [Bitrise](https://www.bitrise.io/) | `ci.BITRISE` | ✅ |
|
43 | | [Buddy](https://buddy.works/) | `ci.BUDDY` | ✅ |
|
44 | | [Buildkite](https://buildkite.com) | `ci.BUILDKITE` | ✅ |
|
45 | | [CircleCI](http://circleci.com) | `ci.CIRCLE` | ✅ |
|
46 | | [Cirrus CI](https://cirrus-ci.org) | `ci.CIRRUS` | ✅ |
|
47 | | [Codeship](https://codeship.com) | `ci.CODESHIP` | 🚫 |
|
48 | | [Drone](https://drone.io) | `ci.DRONE` | ✅ |
|
49 | | [dsari](https://github.com/rfinnie/dsari) | `ci.DSARI` | 🚫 |
|
50 | | [GitLab CI](https://about.gitlab.com/gitlab-ci/) | `ci.GITLAB` | 🚫 |
|
51 | | [GoCD](https://www.go.cd/) | `ci.GOCD` | 🚫 |
|
52 | | [Hudson](http://hudson-ci.org) | `ci.HUDSON` | 🚫 |
|
53 | | [Jenkins CI](https://jenkins-ci.org) | `ci.JENKINS` | ✅ |
|
54 | | [Magnum CI](https://magnum-ci.com) | `ci.MAGNUM` | 🚫 |
|
55 | | [Netlify CI](https://www.netlify.com/) | `ci.NETLIFY` | ✅ |
|
56 | | [Sail CI](https://sail.ci/) | `ci.SAIL` | ✅ |
|
57 | | [Semaphore](https://semaphoreci.com) | `ci.SEMAPHORE` | ✅ |
|
58 | | [Shippable](https://www.shippable.com/) | `ci.SHIPPABLE` | ✅ |
|
59 | | [Solano CI](https://www.solanolabs.com/) | `ci.SOLANO` | ✅ |
|
60 | | [Strider CD](https://strider-cd.github.io/) | `ci.STRIDER` | 🚫 |
|
61 | | [TaskCluster](http://docs.taskcluster.net) | `ci.TASKCLUSTER` | 🚫 |
|
62 | | [TeamCity](https://www.jetbrains.com/teamcity/) by JetBrains | `ci.TEAMCITY` | 🚫 |
|
63 | | [Travis CI](http://travis-ci.org) | `ci.TRAVIS` | ✅ |
|
64 |
|
65 | ## API
|
66 |
|
67 | ### `ci.name`
|
68 |
|
69 | Returns a string containing name of the CI server the code is running on.
|
70 | If CI server is not detected, it returns `null`.
|
71 |
|
72 | Don't depend on the value of this string not to change for a specific
|
73 | vendor. If you find your self writing `ci.name === 'Travis CI'`, you
|
74 | most likely want to use `ci.TRAVIS` instead.
|
75 |
|
76 | ### `ci.isCI`
|
77 |
|
78 | Returns a boolean. Will be `true` if the code is running on a CI server,
|
79 | otherwise `false`.
|
80 |
|
81 | Some CI servers not listed here might still trigger the `ci.isCI`
|
82 | boolean to be set to `true` if they use certain vendor neutral
|
83 | environment variables. In those cases `ci.name` will be `null` and no
|
84 | vendor specific boolean will be set to `true`.
|
85 |
|
86 | ### `ci.isPR`
|
87 |
|
88 | Returns a boolean if PR detection is supported for the current CI server. Will
|
89 | be `true` if a PR is being tested, otherwise `false`. If PR detection is
|
90 | not supported for the current CI server, the value will be `null`.
|
91 |
|
92 | ### `ci.<VENDOR-CONSTANT>`
|
93 |
|
94 | A vendor specific boolean constant is exposed for each support CI
|
95 | vendor. A constant will be `true` if the code is determined to run on
|
96 | the given CI server, otherwise `false`.
|
97 |
|
98 | Examples of vendor constants are `ci.TRAVIS` or `ci.APPVEYOR`. For a
|
99 | complete list, see the support table above.
|
100 |
|
101 | Deprecated vendor constants that will be removed in the next major
|
102 | release:
|
103 |
|
104 | - `ci.TDDIUM` (Solano CI) This have been renamed `ci.SOLANO`
|
105 |
|
106 | ## License
|
107 |
|
108 | [MIT](LICENSE)
|