21434da49a92ab04fd80d64f12cc4bc9eac9fa05d662132012dcb1001e4279e723fa3f18f034d6605297274b92e4689e36b3928484fd58682f580648cb7843 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # ci-info
  2. Get details about the current Continuous Integration environment.
  3. Please [open an
  4. issue](https://github.com/watson/ci-info/issues/new?template=ci-server-not-detected.md)
  5. if your CI server isn't properly detected :)
  6. [![npm](https://img.shields.io/npm/v/ci-info.svg)](https://www.npmjs.com/package/ci-info)
  7. [![Build status](https://travis-ci.org/watson/ci-info.svg?branch=master)](https://travis-ci.org/watson/ci-info)
  8. [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)
  9. ## Installation
  10. ```bash
  11. npm install ci-info --save
  12. ```
  13. ## Usage
  14. ```js
  15. var ci = require('ci-info')
  16. if (ci.isCI) {
  17. console.log('The name of the CI server is:', ci.name)
  18. } else {
  19. console.log('This program is not running on a CI server')
  20. }
  21. ```
  22. ## Supported CI tools
  23. Officially supported CI servers:
  24. | Name | Constant |
  25. |------|----------|
  26. | [AWS CodeBuild](https://aws.amazon.com/codebuild/) | `ci.CODEBUILD` |
  27. | [AppVeyor](http://www.appveyor.com) | `ci.APPVEYOR` |
  28. | [Bamboo](https://www.atlassian.com/software/bamboo) by Atlassian | `ci.BAMBOO` |
  29. | [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) | `ci.BITBUCKET` |
  30. | [Bitrise](https://www.bitrise.io/) | `ci.BITRISE` |
  31. | [Buddy](https://buddy.works/) | `ci.BUDDY` |
  32. | [Buildkite](https://buildkite.com) | `ci.BUILDKITE` |
  33. | [CircleCI](http://circleci.com) | `ci.CIRCLE` |
  34. | [Cirrus CI](https://cirrus-ci.org) | `ci.CIRRUS` |
  35. | [Codeship](https://codeship.com) | `ci.CODESHIP` |
  36. | [Drone](https://drone.io) | `ci.DRONE` |
  37. | [dsari](https://github.com/rfinnie/dsari) | `ci.DSARI` |
  38. | [GitLab CI](https://about.gitlab.com/gitlab-ci/) | `ci.GITLAB` |
  39. | [GoCD](https://www.go.cd/) | `ci.GOCD` |
  40. | [Hudson](http://hudson-ci.org) | `ci.HUDSON` |
  41. | [Jenkins CI](https://jenkins-ci.org) | `ci.JENKINS` |
  42. | [Magnum CI](https://magnum-ci.com) | `ci.MAGNUM` |
  43. | [Sail CI](https://sail.ci/) | `ci.SAIL` |
  44. | [Semaphore](https://semaphoreci.com) | `ci.SEMAPHORE` |
  45. | [Shippable](https://www.shippable.com/) | `ci.SHIPPABLE` |
  46. | [Solano CI](https://www.solanolabs.com/) | `ci.SOLANO` |
  47. | [Strider CD](https://strider-cd.github.io/) | `ci.STRIDER` |
  48. | [TaskCluster](http://docs.taskcluster.net) | `ci.TASKCLUSTER` |
  49. | [Team Foundation Server](https://www.visualstudio.com/en-us/products/tfs-overview-vs.aspx) by Microsoft | `ci.TFS` |
  50. | [TeamCity](https://www.jetbrains.com/teamcity/) by JetBrains | `ci.TEAMCITY` |
  51. | [Travis CI](http://travis-ci.org) | `ci.TRAVIS` |
  52. ## API
  53. ### `ci.name`
  54. A string. Will contain the name of the CI server the code is running on.
  55. If not CI server is detected, it will be `null`.
  56. Don't depend on the value of this string not to change for a specific
  57. vendor. If you find your self writing `ci.name === 'Travis CI'`, you
  58. most likely want to use `ci.TRAVIS` instead.
  59. ### `ci.isCI`
  60. A boolean. Will be `true` if the code is running on a CI server.
  61. Otherwise `false`.
  62. Some CI servers not listed here might still trigger the `ci.isCI`
  63. boolean to be set to `true` if they use certain vendor neutral
  64. environment variables. In those cases `ci.name` will be `null` and no
  65. vendor specific boolean will be set to `true`.
  66. ### `ci.isPR`
  67. A boolean if PR detection is supported for the current CI server. Will
  68. be `true` if a PR is being tested. Otherwise `false`. If PR detection is
  69. not supported for the current CI server, the value will be `null`.
  70. ### `ci.<VENDOR-CONSTANT>`
  71. A vendor specific boolean constants is exposed for each support CI
  72. vendor. A constant will be `true` if the code is determined to run on
  73. the given CI server. Otherwise `false`.
  74. Examples of vendor constants are `ci.TRAVIS` or `ci.APPVEYOR`. For a
  75. complete list, see the support table above.
  76. Deprecated vendor constants that will be removed in the next major
  77. release:
  78. - `ci.TDDIUM` (Solano CI) This have been renamed `ci.SOLANO`
  79. ## License
  80. [MIT](LICENSE)