diff --git a/README.md b/README.md index 7ca697d..0a9b694 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ $ npm install --save env-ci ```js const envCi = require('env-ci'); -const {isCi, service, commit, build, buildUrl, branch, job, jobUrl, pr, isPr, slug, root} = envCi(); +const {isCi, name, service, commit, build, buildUrl, branch, job, jobUrl, pr, isPr, slug, root} = envCi(); ``` ## Variables @@ -27,7 +27,8 @@ const {isCi, service, commit, build, buildUrl, branch, job, jobUrl, pr, isPr, sl | Variable | Description | |------------|-----------------------------------------------------------------------------------| | `isCi` | `true` is running on a CI, `false` otherwise | -| `service` | CI service name | +| `name` | CI service Commercial name (e.g. `Travis CI`, `CircleCI`, `GitLab CI/CD`) | +| `service` | Standardized CI service name (e.g. `travis`, `circleci`, `gitlab`) | | `commit` | Commit sha that triggered the CI build | | `build` | CI service build number | | `buildUrl` | Link to the CI service build | @@ -41,22 +42,22 @@ const {isCi, service, commit, build, buildUrl, branch, job, jobUrl, pr, isPr, sl ## Supported CI -| CI Service | `service` | `isCi` | `commit` | `build` | `buildUrl` | `branch` | `job` | `jobUrl` | `pr` | `isPr` | `slug` | `root` | -|-----------------------------------------------------------------------------------------------------------|:-----------: |:------:|:--------:|:-------:|:----------:|:--------:|:-----:|:--------:|:----:|:------:|:------:|:------:| -| [AppVeyor]( https://www.appveyor.com/docs/environment-variables) | `appveyor` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| [Bamboo](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html) | `bamboo` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | -| [Bitbucket](https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html) | `bitbucket` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | -| [Bitrise](http://devcenter.bitrise.io/faq/available-environment-variables/#exposed-by-bitriseio) | `bitrise` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | -| [Buildkite](https://buildkite.com/docs/builds/environment-variables) | `buildkite` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | -| [Circleci](https://circleci.com/docs/1.0/environment-variables) | `circleci` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | -| [Codeship](https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables) | `codeship` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | -| [Drone](http://readme.drone.io/0.5/usage/environment-reference) | `drone` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | -| [Gitlab CI](https://docs.gitlab.com/ce/ci/variables/README.html) | `gitlab` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | -| [Jenkins](https://wiki.jenkins.io/display/JENKINS/Building+a+software+project) | `jenkins` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | -| [Semaphore](https://semaphoreci.com/docs/available-environment-variables.html) | `semaphore` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | -| [Shippable](http://docs.shippable.com/ci/env-vars/#stdEnv) | `shippable` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | -| [TeamCity](https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters) | `teamcity` | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | -| [Travis](https://docs.travis-ci.com/user/environment-variables) | `travis` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | -| [Wercker](http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name) | `wercker` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | +| CI Service (`name`) | `service` | `isCi` | `commit` | `build` | `buildUrl` | `branch` | `job` | `jobUrl` | `pr` | `isPr` | `slug` | `root` | +|-----------------------------------------------------------------------------------------------------------|:-----------:|:------:|:--------:|:-------:|:----------:|:--------:|:-----:|:--------:|:----:|:------:|:------:|:------:| +| [AppVeyor]( https://www.appveyor.com/docs/environment-variables) | `appveyor` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| [Bamboo](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html) | `bamboo` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | +| [Bitbucket](https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html) | `bitbucket` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | +| [Bitrise](http://devcenter.bitrise.io/faq/available-environment-variables/#exposed-by-bitriseio) | `bitrise` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | +| [Buildkite](https://buildkite.com/docs/builds/environment-variables) | `buildkite` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | +| [CircleCI](https://circleci.com/docs/1.0/environment-variables) | `circleci` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | +| [Codeship](https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables) | `codeship` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | +| [Drone](http://readme.drone.io/0.5/usage/environment-reference) | `drone` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | +| [Gitlab CI/CD](https://docs.gitlab.com/ce/ci/variables/README.html) | `gitlab` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | +| [Jenkins](https://wiki.jenkins.io/display/JENKINS/Building+a+software+project) | `jenkins` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | +| [Semaphore](https://semaphoreci.com/docs/available-environment-variables.html) | `semaphore` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | +| [Shippable](http://docs.shippable.com/ci/env-vars/#stdEnv) | `shippable` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | +| [TeamCity](https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters) | `teamcity` | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | +| [Travis CI](https://docs.travis-ci.com/user/environment-variables) | `travis` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | +| [Wercker](http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name) | `wercker` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | If none of the above CI services is detected, `commit` and `branch` are determined based on the local Git repository, and `isCi` is determined based on the `CI` environment variable. diff --git a/lib/appveyor.js b/lib/appveyor.js index 45f0e7b..6c56cdd 100644 --- a/lib/appveyor.js +++ b/lib/appveyor.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'Appveyor', service: 'appveyor', commit: process.env.APPVEYOR_REPO_COMMIT, build: process.env.APPVEYOR_BUILD_NUMBER, diff --git a/lib/bamboo.js b/lib/bamboo.js index 9d01a45..daed847 100644 --- a/lib/bamboo.js +++ b/lib/bamboo.js @@ -8,6 +8,7 @@ module.exports = { }, configuration() { return { + name: 'Bamboo', service: 'bamboo', commit: process.env.bamboo_planRepository_1_revision, build: process.env.bamboo_buildNumber, diff --git a/lib/bitbucket.js b/lib/bitbucket.js index 8340840..e561f5a 100644 --- a/lib/bitbucket.js +++ b/lib/bitbucket.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'Bitbucket Pipelines', service: 'bitbucket', commit: process.env.BITBUCKET_COMMIT, build: process.env.BITBUCKET_BUILD_NUMBER, diff --git a/lib/bitrise.js b/lib/bitrise.js index 4f8d610..792dc36 100644 --- a/lib/bitrise.js +++ b/lib/bitrise.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'Bitrise', service: 'bitrise', commit: process.env.BITRISE_GIT_COMMIT, build: process.env.BITRISE_BUILD_NUMBER, diff --git a/lib/buildkite.js b/lib/buildkite.js index 20accac..1e766e4 100644 --- a/lib/buildkite.js +++ b/lib/buildkite.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'Buildkite', service: 'buildkite', build: process.env.BUILDKITE_BUILD_NUMBER, buildUrl: process.env.BUILDKITE_BUILD_URL, diff --git a/lib/circleci.js b/lib/circleci.js index dcfac51..81a225a 100644 --- a/lib/circleci.js +++ b/lib/circleci.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'CircleCI', service: 'circleci', build: process.env.CIRCLE_BUILD_NUM, buildUrl: process.env.CIRCLE_BUILD_URL, diff --git a/lib/codeship.js b/lib/codeship.js index 4bfafad..6f05f5f 100644 --- a/lib/codeship.js +++ b/lib/codeship.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'Codeship', service: 'codeship', build: process.env.CI_BUILD_NUMBER, buildUrl: process.env.CI_BUILD_URL, diff --git a/lib/drone.js b/lib/drone.js index 06e224a..48cfcf9 100644 --- a/lib/drone.js +++ b/lib/drone.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'Drone', service: 'drone', commit: process.env.DRONE_COMMIT_SHA, build: process.env.DRONE_BUILD_NUMBER, diff --git a/lib/gitlab.js b/lib/gitlab.js index 4d3e1a8..bb1a5b0 100644 --- a/lib/gitlab.js +++ b/lib/gitlab.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'GitLab CI/CD', service: 'gitlab', commit: process.env.CI_COMMIT_SHA, build: process.env.CI_JOB_NAME, diff --git a/lib/jenkins.js b/lib/jenkins.js index abff7bd..be45bfd 100644 --- a/lib/jenkins.js +++ b/lib/jenkins.js @@ -8,6 +8,7 @@ module.exports = { }, configuration() { return { + name: 'Jenkins', service: 'jenkins', commit: process.env.ghprbActualCommit || process.env.GIT_COMMIT || git.head(), branch: diff --git a/lib/semaphore.js b/lib/semaphore.js index 399f8bd..91d61c1 100644 --- a/lib/semaphore.js +++ b/lib/semaphore.js @@ -8,6 +8,7 @@ module.exports = { }, configuration() { return { + name: 'Semaphore', service: 'semaphore', commit: git.head(), build: process.env.SEMAPHORE_BUILD_NUMBER, diff --git a/lib/shippable.js b/lib/shippable.js index 1107f87..372194e 100644 --- a/lib/shippable.js +++ b/lib/shippable.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'Shippable', service: 'shippable', commit: process.env.COMMIT, build: process.env.BUILD_NUMBER, diff --git a/lib/teamcity.js b/lib/teamcity.js index 463c746..e7870b8 100644 --- a/lib/teamcity.js +++ b/lib/teamcity.js @@ -21,6 +21,7 @@ module.exports = { configuration() { return Object.assign( { + name: 'TeamCity', service: 'teamcity', commit: process.env.BUILD_VCS_NUMBER, build: process.env.BUILD_NUMBER, diff --git a/lib/travis.js b/lib/travis.js index d57ddcb..69ca4be 100644 --- a/lib/travis.js +++ b/lib/travis.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'Travis CI', service: 'travis', commit: process.env.TRAVIS_COMMIT, build: process.env.TRAVIS_BUILD_NUMBER, diff --git a/lib/wercker.js b/lib/wercker.js index 609ffb1..4ca335a 100644 --- a/lib/wercker.js +++ b/lib/wercker.js @@ -6,6 +6,7 @@ module.exports = { }, configuration() { return { + name: 'Wercker', service: 'wercker', commit: process.env.WERCKER_GIT_COMMIT, build: process.env.WERCKER_MAIN_PIPELINE_STARTED, diff --git a/test/appveyor.test.js b/test/appveyor.test.js index 5874341..db38dae 100644 --- a/test/appveyor.test.js +++ b/test/appveyor.test.js @@ -15,6 +15,7 @@ test('Push', t => { delete process.env.APPVEYOR_PULL_REQUEST_NUMBER; t.deepEqual(appveyor.configuration(), { + name: 'Appveyor', service: 'appveyor', commit: '5678', build: '91011', @@ -42,6 +43,7 @@ test('PR', t => { process.env.APPVEYOR_REPO_BRANCH = 'master'; t.deepEqual(appveyor.configuration(), { + name: 'Appveyor', service: 'appveyor', commit: '5678', build: '91011', diff --git a/test/bamboo.test.js b/test/bamboo.test.js index 9dff36f..6602126 100644 --- a/test/bamboo.test.js +++ b/test/bamboo.test.js @@ -12,6 +12,7 @@ test('Push', t => { process.env.bamboo_buildResultsUrl = 'https://server.com/buildresult'; t.deepEqual(bamboo.configuration(), { + name: 'Bamboo', service: 'bamboo', commit: '5678', build: '91011', diff --git a/test/bitbucket.test.js b/test/bitbucket.test.js index 6faf396..1c88e47 100644 --- a/test/bitbucket.test.js +++ b/test/bitbucket.test.js @@ -9,6 +9,7 @@ test('Push', t => { process.env.BITBUCKET_CLONE_DIR = '/'; t.deepEqual(bitbucket.configuration(), { + name: 'Bitbucket Pipelines', service: 'bitbucket', commit: 'b5ce5ce', build: '1964', @@ -27,6 +28,7 @@ test('PR', t => { process.env.BITBUCKET_CLONE_DIR = '/'; t.deepEqual(bitbucket.configuration(), { + name: 'Bitbucket Pipelines', service: 'bitbucket', commit: 'b5ce5ce', build: '1964', diff --git a/test/bitrise.test.js b/test/bitrise.test.js index 23bf029..29e5bbb 100644 --- a/test/bitrise.test.js +++ b/test/bitrise.test.js @@ -11,6 +11,7 @@ test('Push', t => { process.env.BITRISE_APP_SLUG = 'owner/repo'; t.deepEqual(bitrise.configuration(), { + name: 'Bitrise', service: 'bitrise', commit: '5678', build: '91011', @@ -32,6 +33,7 @@ test('PR', t => { process.env.BITRISE_APP_SLUG = 'owner/repo'; t.deepEqual(bitrise.configuration(), { + name: 'Bitrise', service: 'bitrise', commit: '5678', build: '91011', diff --git a/test/buildkite.test.js b/test/buildkite.test.js index d14f567..142a01c 100644 --- a/test/buildkite.test.js +++ b/test/buildkite.test.js @@ -13,6 +13,7 @@ test('Push', t => { process.env.BUILDKITE_PROJECT_SLUG = 'repo'; t.deepEqual(buildkite.configuration(), { + name: 'Buildkite', service: 'buildkite', commit: '5678', build: '91011', @@ -36,6 +37,7 @@ test('PR', t => { process.env.BUILDKITE_PROJECT_SLUG = 'repo'; t.deepEqual(buildkite.configuration(), { + name: 'Buildkite', service: 'buildkite', commit: '5678', build: '91011', diff --git a/test/circleci.test.js b/test/circleci.test.js index 43d09e8..ed17941 100644 --- a/test/circleci.test.js +++ b/test/circleci.test.js @@ -13,6 +13,7 @@ test('Push', t => { delete process.env.CI_PULL_REQUEST; t.deepEqual(circle.configuration(), { + name: 'CircleCI', service: 'circleci', commit: '5678', build: '1234', @@ -36,6 +37,7 @@ test('PR', t => { process.env.CI_PULL_REQUEST = 'uri/pr/10'; t.deepEqual(circle.configuration(), { + name: 'CircleCI', service: 'circleci', commit: '5678', build: '1234', diff --git a/test/codeship.test.js b/test/codeship.test.js index 8f05277..af83976 100644 --- a/test/codeship.test.js +++ b/test/codeship.test.js @@ -10,6 +10,7 @@ test('Push', t => { process.env.CI_REPO_NAME = 'owner/repo'; t.deepEqual(codeship.configuration(), { + name: 'Codeship', service: 'codeship', commit: '5678', build: '91011', diff --git a/test/drone.test.js b/test/drone.test.js index 03ba233..2e58fc6 100644 --- a/test/drone.test.js +++ b/test/drone.test.js @@ -13,6 +13,7 @@ test('Push', t => { delete process.env.DRONE_BUILD_EVENT; t.deepEqual(drone.configuration(), { + name: 'Drone', service: 'drone', commit: '5678', build: '91011', @@ -36,6 +37,7 @@ test('PR', t => { process.env.DRONE_REPO_NAME = 'repo'; t.deepEqual(drone.configuration(), { + name: 'Drone', service: 'drone', commit: '5678', build: '91011', diff --git a/test/gitlab.test.js b/test/gitlab.test.js index fd549b1..8850439 100644 --- a/test/gitlab.test.js +++ b/test/gitlab.test.js @@ -14,6 +14,7 @@ test('Push', t => { process.env.CI_PROJECT_DIR = '/'; t.deepEqual(gitlab.configuration(), { + name: 'GitLab CI/CD', service: 'gitlab', commit: '5678', build: 'job_name', diff --git a/test/jenkins.test.js b/test/jenkins.test.js index e8f2fc7..6c8a571 100644 --- a/test/jenkins.test.js +++ b/test/jenkins.test.js @@ -15,6 +15,7 @@ test('Push', t => { delete process.env.ghprbPullId; t.deepEqual(jenkins.configuration(), { + name: 'Jenkins', service: 'jenkins', commit: '5678', build: '91011', @@ -40,6 +41,7 @@ test('PR', t => { delete process.env.ghprbPullId; t.deepEqual(jenkins.configuration(), { + name: 'Jenkins', service: 'jenkins', commit: '5678', build: '91011', @@ -65,6 +67,7 @@ test('PR (PR builder)', t => { delete process.env.CHANGE_ID; t.deepEqual(jenkins.configuration(), { + name: 'Jenkins', service: 'jenkins', commit: '5678', build: '91011', diff --git a/test/semaphore.test.js b/test/semaphore.test.js index 67402cf..fbaf139 100644 --- a/test/semaphore.test.js +++ b/test/semaphore.test.js @@ -24,6 +24,7 @@ test.serial('Push', async t => { delete process.env.PULL_REQUEST_NUMBER; t.deepEqual(semaphore.configuration(), { + name: 'Semaphore', service: 'semaphore', commit, build: '91011', @@ -45,6 +46,7 @@ test.serial('PR', async t => { process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'; t.deepEqual(semaphore.configuration(), { + name: 'Semaphore', service: 'semaphore', commit, build: '91011', diff --git a/test/shippable.test.js b/test/shippable.test.js index 4b19950..14856d8 100644 --- a/test/shippable.test.js +++ b/test/shippable.test.js @@ -15,6 +15,7 @@ test('Push', t => { delete process.env.BASE_BRANCH; t.deepEqual(shippable.configuration(), { + name: 'Shippable', service: 'shippable', commit: '5678', build: '91011', @@ -42,6 +43,7 @@ test('PR', t => { delete process.env.BRANCH; t.deepEqual(shippable.configuration(), { + name: 'Shippable', service: 'shippable', commit: '5678', build: '91011', diff --git a/test/teamcity.test.js b/test/teamcity.test.js index 9b6cb86..0e7972a 100644 --- a/test/teamcity.test.js +++ b/test/teamcity.test.js @@ -16,6 +16,7 @@ test('Push', t => { fs.writeFileSync(propertiesFile, properties.join('\n') + '\n'); t.deepEqual(teamcity.configuration(), { + name: 'TeamCity', service: 'teamcity', commit: '5678', build: '91011', @@ -33,6 +34,7 @@ test('Push (no properties file)', t => { delete process.env.TEAMCITY_BUILD_PROPERTIES_FILE; t.deepEqual(teamcity.configuration(), { + name: 'TeamCity', service: 'teamcity', commit: '5678', build: '91011', diff --git a/test/travis.test.js b/test/travis.test.js index 084191d..a89235a 100644 --- a/test/travis.test.js +++ b/test/travis.test.js @@ -12,6 +12,7 @@ test('Push', t => { process.env.TRAVIS_REPO_SLUG = 'owner/repo'; t.deepEqual(travis.configuration(), { + name: 'Travis CI', service: 'travis', commit: '5678', build: '91011', @@ -35,6 +36,7 @@ test('PR', t => { process.env.TRAVIS_REPO_SLUG = 'owner/repo'; t.deepEqual(travis.configuration(), { + name: 'Travis CI', service: 'travis', commit: '5678', build: '91011', diff --git a/test/wercker.test.js b/test/wercker.test.js index 244bb36..a153dee 100644 --- a/test/wercker.test.js +++ b/test/wercker.test.js @@ -11,6 +11,7 @@ test('Push', t => { process.env.WERCKER_GIT_REPOSITORY = 'repo'; t.deepEqual(wercker.configuration(), { + name: 'Wercker', service: 'wercker', commit: '5678', build: '123456',