@@ -19,7 +19,7 @@ $ npm install --save env-ci
19
19
``` js
20
20
const envCi = require (' env-ci' );
21
21
22
- const {isCi , name , service , commit , build , buildUrl , branch , job , jobUrl , pr , isPr , slug , root } = envCi ();
22
+ const {name , service , isCi , branch , commit , tag , build , buildUrl , job , jobUrl , isPr , pr , slug , root } = envCi ();
23
23
24
24
if (isCI) {
25
25
console .log (` Building branch ${ branch} of repo ${ slug} on ${ name} ` );
@@ -38,45 +38,46 @@ if (isCI) {
38
38
39
39
| Variable | Description |
40
40
| ------------| -----------------------------------------------------------------------------------|
41
- | ` isCi ` | ` true ` is running on a CI, ` false ` otherwise |
42
41
| ` name ` | CI service Commercial name (e.g. ` Travis CI ` , ` CircleCI ` , ` GitLab CI/CD ` ) |
43
42
| ` service ` | Standardized CI service name (e.g. ` travis ` , ` circleci ` , ` gitlab ` ) |
43
+ | ` isCi ` | ` true ` is running on a CI, ` false ` otherwise |
44
+ | ` branch ` | Git branch being built or targeted by a pull request |
44
45
| ` commit ` | Commit sha that triggered the CI build |
46
+ | ` tag ` | Git tag that triggered the CI build |
45
47
| ` build ` | CI service build number |
46
48
| ` buildUrl ` | Link to the CI service build |
47
- | ` branch ` | Git branch being built or targeted by a pull request |
48
49
| ` job ` | CI service job number |
49
50
| ` jobUrl ` | Link to the CI service job |
50
- | ` pr ` | Pull Request number |
51
51
| ` isPr ` | ` true ` is the build has been triggered by a Pull Request, ` false ` otherwise |
52
- | ` slug ` | The slug (in form: owner_name/repo_name) of the repository currently being built. |
52
+ | ` pr ` | Pull Request number |
53
+ | ` slug ` | The slug (in form: owner_name/repo_name) of the repository currently being built |
53
54
| ` root ` | The path to the directory where the repository is being built |
54
55
55
56
** Note** : Some variables can be detected only on certain CI services. See [ Supported CI] ( #supported-ci ) .
56
57
57
58
## Supported CI
58
59
59
- | CI Service (` name ` ) | ` service ` | ` isCi ` | ` commit ` | ` build ` | ` buildUrl ` | ` branch ` | ` job ` | ` jobUrl ` | ` pr ` | ` isPr ` | ` slug ` | ` root ` |
60
- | ----------------------------------------------------------------------------------------------------------------| :-----------:| :------:| :--------:| :-------:| :----------:| :--------:| :-----:| :--------:| :----:| :-- ----:| :------:| :------:|
61
- | [ AppVeyor] ( https://www.appveyor.com/docs/environment-variables ) | ` appveyor ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
62
- | [ Bamboo] ( https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html ) | ` bamboo ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ |
63
- | [ Bitbucket] ( https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html ) | ` bitbucket ` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
64
- | [ Bitrise] ( http ://devcenter.bitrise.io/faq /available-environment-variables/#exposed-by-bitriseio) | ` bitrise ` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ |
65
- | [ Buddy] ( https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables ) | ` buddy ` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ |
66
- | [ Buildkite] ( https://buildkite.com/docs/builds/environment-variables ) | ` buildkite ` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
67
- | [ CircleCI] ( https://circleci.com/docs/1 .0/environment-variables ) | ` circleci ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ |
68
- | [ Cirrus CI] ( https://cirrus-ci.org/guide/writing-tasks/#environment-variables ) | ` cirrus ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
69
- | [ AWS CodeBuild] ( https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html ) | ` codebuild ` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
70
- | [ Codeship] ( https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables ) | ` codeship ` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ |
71
- | [ Drone] ( http ://readme.drone.io/0.5/usage/environment-reference ) | ` drone ` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ |
72
- | [ Gitlab CI/CD] ( https://docs.gitlab.com/ce/ci/variables/README.html ) | ` gitlab ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ |
73
- | [ Jenkins] ( https://wiki.jenkins.io/display/JENKINS/Building+a+software+project ) | ` jenkins ` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
74
- | [ Semaphore] ( https://semaphoreci.com/docs/available-environment-variables.html ) | ` semaphore ` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ |
75
- | [ Shippable] ( http://docs.shippable.com/ci/env-vars/#stdEnv ) | ` shippable ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ |
76
- | [ TeamCity] ( https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters ) | ` teamcity ` | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
77
- | [ Travis CI] ( https://docs.travis-ci.com/user/environment-variables ) | ` travis ` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ |
78
- | [ Visual Studio Team Services] ( https://docs.microsoft.com/en-us/vsts/pipelines/build/variables ) | ` vsts ` | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ✅ | ✅ | ❌ | ✅ |
79
- | [ Wercker] ( http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name ) | ` wercker ` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
60
+ | CI Service (` name ` ) | ` service ` | ` isCi ` | ` branch ` | ` commit ` | ` tag ` | ` build ` | ` buildUrl ` | ` job ` | ` jobUrl ` | ` isPr ` | ` pr ` | ` slug ` | ` root ` |
61
+ | ---------------------------------------------------------------------------------------------------------------------------------------- | :-----------:| :------:| :--------:| :-------- :| :-----: | : ------- :| :---------- :| :-----:| :--------:| :------ :| :----:| :------:| :------:|
62
+ | [ AppVeyor] ( https://www.appveyor.com/docs/environment-variables ) | ` appveyor ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
63
+ | [ Bamboo] ( https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html ) | ` bamboo ` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ |
64
+ | [ Bitbucket] ( https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html ) | ` bitbucket ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
65
+ | [ Bitrise] ( https ://devcenter.bitrise.io/builds /available-environment-variables/#exposed-by-bitriseio) | ` bitrise ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ |
66
+ | [ Buddy] ( https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables ) | ` buddy ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ |
67
+ | [ Buildkite] ( https://buildkite.com/docs/builds/environment-variables ) | ` buildkite ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
68
+ | [ CircleCI] ( https://circleci.com/docs/2 .0/env-vars/#built-in- environment-variables ) | ` circleci ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ |
69
+ | [ Cirrus CI] ( https://cirrus-ci.org/guide/writing-tasks/#environment-variables ) | ` cirrus ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
70
+ | [ AWS CodeBuild] ( https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html ) | ` codebuild ` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
71
+ | [ Codeship] ( https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables/#default-environment-variables ) | ` codeship ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ |
72
+ | [ Drone] ( https ://readme.drone.io/reference/environ/ ) | ` drone ` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ |
73
+ | [ Gitlab CI/CD] ( https://docs.gitlab.com/ce/ci/variables/README.html ) | ` gitlab ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ |
74
+ | [ Jenkins] ( https://wiki.jenkins.io/display/JENKINS/Building+a+software+project ) | ` jenkins ` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
75
+ | [ Semaphore] ( https://semaphoreci.com/docs/available-environment-variables.html ) | ` semaphore ` | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ |
76
+ | [ Shippable] ( http://docs.shippable.com/ci/env-vars/#stdEnv ) | ` shippable ` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ |
77
+ | [ TeamCity] ( https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters ) | ` teamcity ` | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
78
+ | [ Travis CI] ( https://docs.travis-ci.com/user/environment-variables#default-environment-variables ) | ` travis ` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ |
79
+ | [ Visual Studio Team Services] ( https://docs.microsoft.com/en-us/vsts/pipelines/build/variables ) | ` vsts ` | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ✅ |
80
+ | [ Wercker] ( http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name ) | ` wercker ` | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ |
80
81
81
82
** Note** : 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.
82
83
0 commit comments