Installing dependencies.
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Pierre Vanduynslager
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
# env-ci
|
||||
|
||||
Get environment variables exposed by CI services.
|
||||
|
||||
[](https://github.com/semantic-release/env-ci/actions?query=workflow%3ATest+branch%3Amaster)
|
||||
[](https://www.npmjs.com/package/env-ci)
|
||||
|
||||
Adapted from [codecov-node](https://github.com/codecov/codecov-node/blob/master/lib/detect.js).
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
$ npm install --save env-ci
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const envCi = require("env-ci");
|
||||
|
||||
const { name, service, isCi, branch, commit, tag, build, buildUrl, job, jobUrl, isPr, pr, prBranch, slug, root } =
|
||||
envCi();
|
||||
|
||||
if (isCI) {
|
||||
console.log(`Building repo ${slug} on ${name} service`);
|
||||
|
||||
if (isPr) {
|
||||
console.log(`Building Pull Request #${pr} originating from branch ${prBranch} and targeting branch ${branch}`);
|
||||
} else {
|
||||
console.log(`Building branch ${branch}`);
|
||||
}
|
||||
|
||||
if (service === "travis") {
|
||||
// Do something specific to Travis CI
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Supported variables
|
||||
|
||||
| Variable | Description |
|
||||
| ---------- | ------------------------------------------------------------------------------------------------------ |
|
||||
| `name` | CI service Commercial name (e.g. `Travis CI`, `CircleCI`, `GitLab CI/CD`) |
|
||||
| `service` | Standardized CI service name (e.g. `travis`, `circleci`, `gitlab`) |
|
||||
| `isCi` | `true` is running on a CI, `false` otherwise |
|
||||
| `branch` | Git branch being built or targeted by a Pull Request |
|
||||
| `commit` | Commit sha that triggered the CI build |
|
||||
| `tag` | Git tag that triggered the CI build |
|
||||
| `build` | CI service build number |
|
||||
| `buildUrl` | Link to the CI service build |
|
||||
| `job` | CI service job number |
|
||||
| `jobUrl` | Link to the CI service job |
|
||||
| `isPr` | `true` if the build has been triggered by a Pull Request, `false` otherwise |
|
||||
| `pr` | Pull Request number (only for builds triggered by a Pull Request) |
|
||||
| `prBranch` | Git branch branch from which the Pull Request originated (only for builds triggered by a Pull Request) |
|
||||
| `slug` | The slug (in form: owner_name/repo_name) of the repository currently being built |
|
||||
| `root` | The path to the directory where the repository is being built |
|
||||
|
||||
**Note**: Some variables can be detected only on certain CI services. See [Supported CI](#supported-ci).
|
||||
|
||||
**Note**: The `pr` and `prBranch` properties are only available for builds triggered when a Pull Request is opened/updated and not on builds triggered by a push on a branch even if that branch happens to be the branch from which the Pull Request originated.
|
||||
|
||||
## Supported CI
|
||||
|
||||
| CI Service (`name`) | `service` | `isCi` | `branch` | `commit` | `tag` | `build` | `buildUrl` | `job` | `jobUrl` | `isPr` | `pr` | `prBranch` | `slug` | `root` |
|
||||
| -------------------------------------------------------------------------------------------------------------------------------------- | :-----------: | :----------------: | :-------------------------: | :----------------: | :---------------------: | :----------------: | :----------------: | :----------------: | :----------------: | :-------------------: | :-------------------: | :-------------------: | :----------------: | :----------------: |
|
||||
| [AppVeyor](https://www.appveyor.com/docs/environment-variables) | `appveyor` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [Bamboo](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html) | `bamboo` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: |
|
||||
| [Bitbucket](https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html) | `bitbucket` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: |
|
||||
| [Bitrise](https://devcenter.bitrise.io/builds/available-environment-variables/#exposed-by-bitriseio) | `bitrise` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
|
||||
| [Buddy](https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables) | `buddy` | :white_check_mark: | [:warning:](#buddy) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: |
|
||||
| [Buildkite](https://buildkite.com/docs/builds/environment-variables) | `buildkite` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [CircleCI](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables) | `circleci` | :white_check_mark: | [:warning:](#circleci) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: |
|
||||
| [Cirrus CI](https://cirrus-ci.org/guide/writing-tasks/#environment-variables) | `cirrus` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [Cloudflare Pages](https://developers.cloudflare.com/pages/platform/build-configuration#environment-variables) | `cloudflarePages` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: |
|
||||
| [AWS CodeBuild](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html) | `codebuild` | :white_check_mark: | [:warning:](#aws-codebuild) | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: |
|
||||
| [Codefresh](https://codefresh.io/docs/docs/codefresh-yaml/variables#system-provided-variables) | `codefresh` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [Codeship](https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables/#default-environment-variables) | `codeship` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :x: |
|
||||
| [Drone](https://readme.drone.io/reference/environ/) | `drone` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables) | `github` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [GitLab CI/CD](https://docs.gitlab.com/ce/ci/variables/README.html) | `gitlab` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [Jenkins](https://wiki.jenkins.io/display/JENKINS/Building+a+software+project) | `jenkins` | :white_check_mark: | [:warning:](#jenkins) | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | [:warning:](#jenkins) | [:warning:](#jenkins) | [:warning:](#jenkins) | :white_check_mark: | :white_check_mark: |
|
||||
| [Netlify](https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables) | `netlify` | :white_check_mark: | [:warning:](#netlify) | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [Puppet](https://puppet.com/docs/pipelines-for-apps/enterprise/environment-variable.html) | `puppet` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: |
|
||||
| [Sail CI](https://sail.ci/docs/environment-variables) | `sail` | :white_check_mark: | [:warning:](#sail) | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: |
|
||||
| [Scrutinizer](https://scrutinizer-ci.com/docs/build/environment-variables) | `scrutinizer` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: |
|
||||
| [Semaphore](https://docs.semaphoreci.com/article/12-environment-variables) | `semaphore` | :white_check_mark: | [:warning:](#semaphore) | :white_check_mark: | [:warning:](#semaphore) | :white_check_mark: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [Shippable](http://docs.shippable.com/ci/env-vars/#stdEnv) | `shippable` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [TeamCity](https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters) | `teamcity` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: |
|
||||
| [Travis CI](https://docs.travis-ci.com/user/environment-variables#default-environment-variables) | `travis` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [Vela](https://go-vela.github.io/docs/reference/environment/variables/) | `vela` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| [Vercel](https://vercel.com/docs/environment-variables) | `vercel` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :x: |
|
||||
| [Visual Studio Team Services](https://docs.microsoft.com/en-us/vsts/pipelines/build/variables) | `vsts` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
|
||||
| [Wercker](http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name) | `wercker` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: | :x: | :x: | :white_check_mark: | :white_check_mark: |
|
||||
|
||||
:warning: See [Caveats](#caveats)
|
||||
|
||||
**Note**: Unsupported properties will always be `undefined`. For example if a Ci services doesn't support triggering builds when a Pull Request is opened/updated, `isPr` will be `undefined`.
|
||||
|
||||
**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.
|
||||
|
||||
## API
|
||||
|
||||
### envCi(options) => Result
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
#### env
|
||||
|
||||
Type: `Object`<br>
|
||||
Default: `process.env`
|
||||
|
||||
The object to read environment variables from.
|
||||
|
||||
#### cwd
|
||||
|
||||
Type: `String`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
The current working directory in which to execute `git` commands used to determine the `commit` and `branch` [Result](#result) properties in case no [supported CI](#supported-ci) is detected.
|
||||
|
||||
### Result
|
||||
|
||||
Type: `Object`
|
||||
|
||||
[Environment variables values](#supported-variables) exposed by the CI service.
|
||||
|
||||
## Caveats
|
||||
|
||||
### AWS CodeBuild
|
||||
|
||||
AWS CodeBuild doesn't provide an environment variable to determine the current Git branch being built. In addition, it clones the repository in a [detached head state](https://git-scm.com/docs/git-checkout#_detached_head) so the branch cannot be determined with `git rev-parse --abbrev-ref HEAD`.
|
||||
To work around this limitation, `env-ci` look for the remote branches having the same `HEAD` as the local detached `HEAD` to determine the branch from which the detached `HEAD` was created.
|
||||
In the rare case where there is multiple remote branches with the same `HEAD` as the local detached `HEAD`, `env-ci` will arbitrarily pick the first one. This can lead to an inaccurate `branch` value in such circumstances.
|
||||
|
||||
### Buddy
|
||||
|
||||
For builds triggered when [a Pull Request is opened/updated](https://buddy.works/knowledge/deployments/pull-requests), Buddy doesn't provide an environment variable indicating the branch from which the Pull Request originated nor the target branch. It also build from a branch named `pull/<PR number>` so the target branch cannot be determined with a `git` command.
|
||||
Therefore in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` and `prBranch` properties.
|
||||
|
||||
See [feature request](https://forum.buddy.works/t/determine-pull-request-branch-with-environment-variable/911).
|
||||
|
||||
### CircleCI
|
||||
|
||||
For builds triggered when a Pull Request is opened/updated, CircleCI doesn't provide an environment variable indicating the target branch.
|
||||
Therefore in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property. However `prBranch` will be set.
|
||||
|
||||
See [feature request](https://discuss.circleci.com/t/create-a-circle-target-branch-envar/10022).
|
||||
|
||||
### Cloudflare Pages
|
||||
|
||||
For builds triggered when a Pull Request is opened/updated, Cloudflare Pages will re-use the branch variable for the originating branch and not provide a target. Therefore `env-ci` will not be able to determine the `prBranch` property however `branch` will always be set.
|
||||
|
||||
### Jenkins
|
||||
|
||||
Triggering build when a Pull Request is opened/updated is supported only via the [ghprb-plugin](https://github.com/jenkinsci/ghprb-plugin) and [gitlab-plugin](https://github.com/jenkinsci/gitlab-plugin). Therefore `env-ci` will set `isPr`, `pr` and `prBranch` and define `branch` with the Pull Request target branch only if one those plugin is used.
|
||||
|
||||
### Netlify
|
||||
|
||||
For builds triggered when a Pull Request is opened/updated, Netlify doesn't provide an environment variable indicating the target branch.
|
||||
Therefore in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property. However `prBranch` will be set.
|
||||
|
||||
See [feature request](https://answers.netlify.com/t/access-pr-target-branch-when-deploying-preview-build/32402)
|
||||
|
||||
### Sail
|
||||
|
||||
For builds triggered when a Pull Request is opened/updated, Sail doesn't provide an environment variable indicating the target branch, and the one for the current branch is set to `pull/<PR number>` independently of the the branch name from which the Pull Request originated.
|
||||
Therefore in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` and `prBranch` properties.
|
||||
|
||||
### Semaphore
|
||||
|
||||
For builds triggered when a Pull Request is opened/updated, Semaphore 1.0 doesn't provide an environment variable indicating the target branch.
|
||||
Therefore in the case of Pull Request builds, `env-ci` will not be able to determine the `branch` property. However `prBranch` will be set.
|
||||
On Semaphore 2.0 the `branch` and `prBranch` properties will work as expected.
|
||||
|
||||
The property `tag` is only available on Semaphore 2.0.
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
const process = require('process');
|
||||
const git = require('./services/git.js');
|
||||
|
||||
const services = {
|
||||
appveyor: require('./services/appveyor.js'),
|
||||
bamboo: require('./services/bamboo.js'),
|
||||
bitbucket: require('./services/bitbucket.js'),
|
||||
bitrise: require('./services/bitrise.js'),
|
||||
buddy: require('./services/buddy.js'),
|
||||
buildkite: require('./services/buildkite.js'),
|
||||
circleci: require('./services/circleci.js'),
|
||||
cirrus: require('./services/cirrus.js'),
|
||||
cloudflarePages: require('./services/cloudflare-pages.js'),
|
||||
codebuild: require('./services/codebuild.js'),
|
||||
codefresh: require('./services/codefresh.js'),
|
||||
codeship: require('./services/codeship.js'),
|
||||
drone: require('./services/drone.js'),
|
||||
github: require('./services/github.js'),
|
||||
gitlab: require('./services/gitlab.js'),
|
||||
jenkins: require('./services/jenkins.js'),
|
||||
netlify: require('./services/netlify.js'),
|
||||
puppet: require('./services/puppet.js'),
|
||||
sail: require('./services/sail.js'),
|
||||
scrutinizer: require('./services/scrutinizer.js'),
|
||||
semaphore: require('./services/semaphore.js'),
|
||||
shippable: require('./services/shippable.js'),
|
||||
teamcity: require('./services/teamcity.js'),
|
||||
travis: require('./services/travis.js'),
|
||||
vela: require('./services/vela.js'),
|
||||
vercel: require('./services/vercel.js'),
|
||||
vsts: require('./services/vsts.js'),
|
||||
wercker: require('./services/wercker.js'),
|
||||
};
|
||||
|
||||
module.exports = ({env = process.env, cwd = process.cwd()} = {}) => {
|
||||
for (const name of Object.keys(services)) {
|
||||
if (services[name].detect({env, cwd})) {
|
||||
return {isCi: true, ...services[name].configuration({env, cwd})};
|
||||
}
|
||||
}
|
||||
|
||||
return {isCi: Boolean(env.CI), ...git.configuration({env, cwd})};
|
||||
};
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
const execa = require('execa');
|
||||
|
||||
function head(options) {
|
||||
try {
|
||||
return execa.sync('git', ['rev-parse', 'HEAD'], options).stdout;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function branch(options) {
|
||||
try {
|
||||
const headRef = execa.sync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], options).stdout;
|
||||
|
||||
if (headRef === 'HEAD') {
|
||||
const branch = execa
|
||||
.sync('git', ['show', '-s', '--pretty=%d', 'HEAD'], options)
|
||||
.stdout.replace(/^\(|\)$/g, '')
|
||||
.split(', ')
|
||||
.find((branch) => branch.startsWith('origin/'));
|
||||
return branch ? branch.match(/^origin\/(?<branch>.+)/)[1] : undefined;
|
||||
}
|
||||
|
||||
return headRef;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {head, branch};
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
function prNumber(pr) {
|
||||
return (/\d+(?!.*\d+)/.exec(pr) || [])[0];
|
||||
}
|
||||
|
||||
function parseBranch(branch) {
|
||||
return branch ? /^(?:refs\/heads\/)?(?<branch>.+)$/i.exec(branch)[1] : undefined;
|
||||
}
|
||||
|
||||
module.exports = {prNumber, parseBranch};
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
{
|
||||
"name": "env-ci",
|
||||
"description": "Get environment variables exposed by CI services",
|
||||
"version": "5.5.0",
|
||||
"author": "Pierre Vanduynslager (https://github.com/pvdlg)",
|
||||
"ava": {
|
||||
"files": [
|
||||
"test/**/*.test.js"
|
||||
]
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/semantic-release/env-ci/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"execa": "^5.0.0",
|
||||
"fromentries": "^1.3.2",
|
||||
"java-properties": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "3.15.0",
|
||||
"codecov": "3.8.3",
|
||||
"file-url": "3.0.0",
|
||||
"nyc": "15.1.0",
|
||||
"proxyquire": "2.1.3",
|
||||
"tempy": "0.7.1",
|
||||
"xo": "0.47.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.17"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lib",
|
||||
"services"
|
||||
],
|
||||
"homepage": "https://github.com/semantic-release/env-ci#readme",
|
||||
"keywords": [
|
||||
"appveyor",
|
||||
"bamboo",
|
||||
"bitbucket",
|
||||
"bitrise",
|
||||
"buddy",
|
||||
"buildkite",
|
||||
"ci",
|
||||
"circle",
|
||||
"cirrus",
|
||||
"cloudflare",
|
||||
"codebuild",
|
||||
"codefresh",
|
||||
"codeship",
|
||||
"drone",
|
||||
"environment",
|
||||
"git",
|
||||
"github",
|
||||
"gitlab",
|
||||
"jenkins",
|
||||
"netlify",
|
||||
"puppet",
|
||||
"sail",
|
||||
"scrutinizer",
|
||||
"semaphore",
|
||||
"shippable",
|
||||
"teamcity",
|
||||
"travis",
|
||||
"variable",
|
||||
"vsts",
|
||||
"wercker"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"nyc": {
|
||||
"include": [
|
||||
"index.js",
|
||||
"lib/**/*.js",
|
||||
"services/**/*.js"
|
||||
],
|
||||
"reporter": [
|
||||
"json",
|
||||
"text",
|
||||
"html"
|
||||
],
|
||||
"all": true
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 120,
|
||||
"trailingComma": "es5"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/semantic-release/env-ci.git"
|
||||
},
|
||||
"scripts": {
|
||||
"codecov": "codecov -f coverage/coverage-final.json",
|
||||
"lint": "xo",
|
||||
"semantic-release": "semantic-release",
|
||||
"test": "npm run lint && npm run test:ci",
|
||||
"test:ci": "nyc ava -v"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"space": true,
|
||||
"rules": {
|
||||
"unicorn/string-content": "off",
|
||||
"unicorn/prefer-module": "off"
|
||||
}
|
||||
},
|
||||
"renovate": {
|
||||
"extends": [
|
||||
"github>semantic-release/.github"
|
||||
]
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// https://www.appveyor.com/docs/environment-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.APPVEYOR);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.APPVEYOR_PULL_REQUEST_NUMBER;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Appveyor',
|
||||
service: 'appveyor',
|
||||
commit: env.APPVEYOR_REPO_COMMIT,
|
||||
tag: env.APPVEYOR_REPO_TAG_NAME,
|
||||
build: env.APPVEYOR_BUILD_NUMBER,
|
||||
buildUrl: `https://ci.appveyor.com/project/${env.APPVEYOR_PROJECT_SLUG}/build/${env.APPVEYOR_BUILD_VERSION}`,
|
||||
branch: env.APPVEYOR_REPO_BRANCH,
|
||||
job: env.APPVEYOR_JOB_NUMBER,
|
||||
jobUrl: `https://ci.appveyor.com/project/${env.APPVEYOR_PROJECT_SLUG}/build/job/${env.APPVEYOR_JOB_ID}`,
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: env.APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH,
|
||||
slug: env.APPVEYOR_REPO_NAME,
|
||||
root: env.APPVEYOR_BUILD_FOLDER,
|
||||
};
|
||||
},
|
||||
};
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.bamboo_agentId);
|
||||
},
|
||||
configuration({env}) {
|
||||
return {
|
||||
name: 'Bamboo',
|
||||
service: 'bamboo',
|
||||
commit: env.bamboo_planRepository_1_revision,
|
||||
build: env.bamboo_buildNumber,
|
||||
buildUrl: env.bamboo_buildResultsUrl,
|
||||
branch: env.bamboo_planRepository_1_branchName,
|
||||
job: env.bamboo_buildKey,
|
||||
root: env.bamboo_build_working_directory,
|
||||
};
|
||||
},
|
||||
};
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.BITBUCKET_BUILD_NUMBER);
|
||||
},
|
||||
configuration({env}) {
|
||||
return {
|
||||
name: 'Bitbucket Pipelines',
|
||||
service: 'bitbucket',
|
||||
commit: env.BITBUCKET_COMMIT,
|
||||
tag: env.BITBUCKET_TAG,
|
||||
build: env.BITBUCKET_BUILD_NUMBER,
|
||||
buildUrl: `https://bitbucket.org/${env.BITBUCKET_REPO_SLUG}/addon/pipelines/home#!/results/${env.BITBUCKET_BUILD_NUMBER}`,
|
||||
branch: env.BITBUCKET_BRANCH,
|
||||
slug: env.BITBUCKET_REPO_SLUG,
|
||||
root: env.BITBUCKET_CLONE_DIR,
|
||||
};
|
||||
},
|
||||
};
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// https://devcenter.bitrise.io/builds/available-environment-variables/#exposed-by-bitriseio
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.BITRISE_IO);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.BITRISE_PULL_REQUEST === 'false' ? undefined : env.BITRISE_PULL_REQUEST;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Bitrise',
|
||||
service: 'bitrise',
|
||||
commit: env.BITRISE_GIT_COMMIT,
|
||||
tag: env.BITRISE_GIT_TAG,
|
||||
build: env.BITRISE_BUILD_NUMBER,
|
||||
buildUrl: env.BITRISE_BUILD_URL,
|
||||
branch: isPr ? env.BITRISEIO_GIT_BRANCH_DEST : env.BITRISE_GIT_BRANCH,
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: isPr ? env.BITRISE_GIT_BRANCH : undefined,
|
||||
slug: env.BITRISE_APP_SLUG,
|
||||
};
|
||||
},
|
||||
};
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// https://buddy.works/knowledge/deployments/how-use-environment-variables#default-environment-variables
|
||||
|
||||
const {prNumber} = require('../lib/utils.js');
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.BUDDY_WORKSPACE_ID);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = prNumber(env.BUDDY_EXECUTION_PULL_REQUEST_ID);
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Buddy',
|
||||
service: 'buddy',
|
||||
commit: env.BUDDY_EXECUTION_REVISION,
|
||||
tag: env.BUDDY_EXECUTION_TAG,
|
||||
build: env.BUDDY_EXECUTION_ID,
|
||||
buildUrl: env.BUDDY_EXECUTION_URL,
|
||||
branch: isPr ? undefined : env.BUDDY_EXECUTION_BRANCH,
|
||||
pr,
|
||||
isPr,
|
||||
slug: env.BUDDY_REPO_SLUG,
|
||||
};
|
||||
},
|
||||
};
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// https://buildkite.com/docs/builds/environment-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.BUILDKITE);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.BUILDKITE_PULL_REQUEST === 'false' ? undefined : env.BUILDKITE_PULL_REQUEST;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Buildkite',
|
||||
service: 'buildkite',
|
||||
build: env.BUILDKITE_BUILD_NUMBER,
|
||||
buildUrl: env.BUILDKITE_BUILD_URL,
|
||||
commit: env.BUILDKITE_COMMIT,
|
||||
tag: env.BUILDKITE_TAG,
|
||||
branch: isPr ? env.BUILDKITE_PULL_REQUEST_BASE_BRANCH : env.BUILDKITE_BRANCH,
|
||||
slug: `${env.BUILDKITE_ORGANIZATION_SLUG}/${env.BUILDKITE_PROJECT_SLUG}`,
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: isPr ? env.BUILDKITE_BRANCH : undefined,
|
||||
root: env.BUILDKITE_BUILD_CHECKOUT_PATH,
|
||||
};
|
||||
},
|
||||
};
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
|
||||
|
||||
const {prNumber} = require('../lib/utils.js');
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.CIRCLECI);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.CIRCLE_PR_NUMBER || prNumber(env.CIRCLE_PULL_REQUEST || env.CI_PULL_REQUEST);
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'CircleCI',
|
||||
service: 'circleci',
|
||||
build: env.CIRCLE_BUILD_NUM,
|
||||
buildUrl: env.CIRCLE_BUILD_URL,
|
||||
job: `${env.CIRCLE_BUILD_NUM}.${env.CIRCLE_NODE_INDEX}`,
|
||||
commit: env.CIRCLE_SHA1,
|
||||
tag: env.CIRCLE_TAG,
|
||||
branch: isPr ? undefined : env.CIRCLE_BRANCH,
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: isPr ? env.CIRCLE_BRANCH : undefined,
|
||||
slug: `${env.CIRCLE_PROJECT_USERNAME}/${env.CIRCLE_PROJECT_REPONAME}`,
|
||||
};
|
||||
},
|
||||
};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// https://cirrus-ci.org/guide/writing-tasks/#environment-variables
|
||||
|
||||
const CIRRUS_CI_DASHBOARD = 'https://cirrus-ci.com';
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.CIRRUS_CI);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.CIRRUS_PR;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Cirrus CI',
|
||||
service: 'cirrus',
|
||||
commit: env.CIRRUS_CHANGE_IN_REPO,
|
||||
tag: env.CIRRUS_TAG,
|
||||
build: env.CIRRUS_BUILD_ID,
|
||||
buildUrl: `${CIRRUS_CI_DASHBOARD}/build/${env.CIRRUS_BUILD_ID}`,
|
||||
job: env.CIRRUS_TASK_ID,
|
||||
jobUrl: `${CIRRUS_CI_DASHBOARD}/task/${env.CIRRUS_TASK_ID}`,
|
||||
branch: isPr ? env.CIRRUS_BASE_BRANCH : env.CIRRUS_BRANCH,
|
||||
pr,
|
||||
isPr,
|
||||
slug: env.CIRRUS_REPO_FULL_NAME,
|
||||
root: env.CIRRUS_WORKING_DIR,
|
||||
};
|
||||
},
|
||||
};
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// https://developers.cloudflare.com/pages/platform/build-configuration#environment-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return env.CF_PAGES === '1';
|
||||
},
|
||||
configuration({env}) {
|
||||
return {
|
||||
name: 'Cloudflare Pages',
|
||||
service: 'cloudflarePages',
|
||||
commit: env.CF_PAGES_COMMIT_SHA,
|
||||
branch: env.CF_PAGES_BRANCH,
|
||||
root: env.PWD,
|
||||
};
|
||||
},
|
||||
};
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
const {head, branch} = require('../lib/git.js');
|
||||
|
||||
// https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.CODEBUILD_BUILD_ID);
|
||||
},
|
||||
configuration({env, cwd}) {
|
||||
return {
|
||||
name: 'AWS CodeBuild',
|
||||
service: 'codebuild',
|
||||
commit: head({env, cwd}),
|
||||
build: env.CODEBUILD_BUILD_ID,
|
||||
branch: branch({env, cwd}),
|
||||
buildUrl: `https://console.aws.amazon.com/codebuild/home?region=${env.AWS_REGION}#/builds/${env.CODEBUILD_BUILD_ID}/view/new`,
|
||||
root: env.PWD,
|
||||
};
|
||||
},
|
||||
};
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// https://codefresh.io/docs/docs/codefresh-yaml/variables#system-provided-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.CF_BUILD_ID);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.CF_PULL_REQUEST_NUMBER;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Codefresh',
|
||||
service: 'codefresh',
|
||||
commit: env.CF_REVISION,
|
||||
build: env.CF_BUILD_ID,
|
||||
buildUrl: env.CF_BUILD_URL,
|
||||
branch: isPr ? env.CF_PULL_REQUEST_TARGET : env.CF_BRANCH,
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: isPr ? env.CF_BRANCH : undefined,
|
||||
slug: `${env.CF_REPO_OWNER}/${env.CF_REPO_NAME}`,
|
||||
root: env.CF_VOLUME_PATH,
|
||||
};
|
||||
},
|
||||
};
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// https://documentation.codeship.com/basic/builds-and-configuration/set-environment-variables/#default-environment-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return env.CI_NAME && env.CI_NAME === 'codeship';
|
||||
},
|
||||
configuration({env}) {
|
||||
return {
|
||||
name: 'Codeship',
|
||||
service: 'codeship',
|
||||
build: env.CI_BUILD_NUMBER,
|
||||
buildUrl: env.CI_BUILD_URL,
|
||||
commit: env.CI_COMMIT_ID,
|
||||
branch: env.CI_BRANCH,
|
||||
slug: env.CI_REPO_NAME,
|
||||
};
|
||||
},
|
||||
};
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// https://readme.drone.io/reference/environ
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.DRONE);
|
||||
},
|
||||
configuration({env}) {
|
||||
const isPr = env.DRONE_BUILD_EVENT === 'pull_request';
|
||||
|
||||
return {
|
||||
name: 'Drone',
|
||||
service: 'drone',
|
||||
commit: env.DRONE_COMMIT_SHA,
|
||||
tag: env.DRONE_TAG,
|
||||
build: env.DRONE_BUILD_NUMBER,
|
||||
buildUrl: env.DRONE_BUILD_LINK,
|
||||
branch: isPr ? env.DRONE_TARGET_BRANCH : env.DRONE_BRANCH,
|
||||
job: env.DRONE_JOB_NUMBER,
|
||||
jobUrl: env.DRONE_BUILD_LINK,
|
||||
pr: env.DRONE_PULL_REQUEST,
|
||||
isPr,
|
||||
prBranch: isPr ? env.DRONE_SOURCE_BRANCH : undefined,
|
||||
slug: `${env.DRONE_REPO_OWNER}/${env.DRONE_REPO_NAME}`,
|
||||
root: env.DRONE_WORKSPACE,
|
||||
};
|
||||
},
|
||||
};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
const {head, branch} = require('../lib/git.js');
|
||||
|
||||
module.exports = {
|
||||
configuration(options) {
|
||||
return {commit: head(options), branch: branch(options)};
|
||||
},
|
||||
};
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
||||
const {parseBranch} = require('../lib/utils.js');
|
||||
|
||||
const getPrEvent = ({env}) => {
|
||||
try {
|
||||
const event = env.GITHUB_EVENT_PATH ? require(env.GITHUB_EVENT_PATH) : undefined;
|
||||
|
||||
if (event && event.pull_request) {
|
||||
return {
|
||||
branch: event.pull_request.base ? parseBranch(event.pull_request.base.ref) : undefined,
|
||||
pr: event.pull_request.number,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// Noop
|
||||
}
|
||||
|
||||
return {pr: undefined, branch: undefined};
|
||||
};
|
||||
|
||||
const getPrNumber = (env) => {
|
||||
const event = env.GITHUB_EVENT_PATH ? require(env.GITHUB_EVENT_PATH) : undefined;
|
||||
return event && event.pull_request ? event.pull_request.number : undefined;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.GITHUB_ACTIONS);
|
||||
},
|
||||
configuration({env, cwd}) {
|
||||
const isPr = env.GITHUB_EVENT_NAME === 'pull_request' || env.GITHUB_EVENT_NAME === 'pull_request_target';
|
||||
const branch = parseBranch(
|
||||
env.GITHUB_EVENT_NAME === 'pull_request_target' ? `refs/pull/${getPrNumber(env)}/merge` : env.GITHUB_REF
|
||||
);
|
||||
|
||||
return {
|
||||
name: 'GitHub Actions',
|
||||
service: 'github',
|
||||
commit: env.GITHUB_SHA,
|
||||
build: env.GITHUB_RUN_ID,
|
||||
isPr,
|
||||
branch,
|
||||
prBranch: isPr ? branch : undefined,
|
||||
slug: env.GITHUB_REPOSITORY,
|
||||
root: env.GITHUB_WORKSPACE,
|
||||
...(isPr ? getPrEvent({env, cwd}) : undefined),
|
||||
};
|
||||
},
|
||||
};
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// https://docs.gitlab.com/ce/ci/variables/README.html
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.GITLAB_CI);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.CI_MERGE_REQUEST_ID;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'GitLab CI/CD',
|
||||
service: 'gitlab',
|
||||
commit: env.CI_COMMIT_SHA,
|
||||
tag: env.CI_COMMIT_TAG,
|
||||
build: env.CI_PIPELINE_ID,
|
||||
buildUrl: `${env.CI_PROJECT_URL}/pipelines/${env.CI_PIPELINE_ID}`,
|
||||
job: env.CI_JOB_ID,
|
||||
jobUrl: `${env.CI_PROJECT_URL}/-/jobs/${env.CI_JOB_ID}`,
|
||||
branch: isPr ? env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME : env.CI_COMMIT_REF_NAME,
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME,
|
||||
slug: env.CI_PROJECT_PATH,
|
||||
root: env.CI_PROJECT_DIR,
|
||||
};
|
||||
},
|
||||
};
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
const {head} = require('../lib/git.js');
|
||||
|
||||
// https://wiki.jenkins.io/display/JENKINS/Building+a+software+project
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.JENKINS_URL);
|
||||
},
|
||||
configuration({env, cwd}) {
|
||||
const pr = env.ghprbPullId || env.gitlabMergeRequestId || env.CHANGE_ID;
|
||||
const isPr = Boolean(pr);
|
||||
const localBranch = env.GIT_LOCAL_BRANCH || env.GIT_BRANCH || env.gitlabBranch || env.BRANCH_NAME;
|
||||
|
||||
return {
|
||||
name: 'Jenkins',
|
||||
service: 'jenkins',
|
||||
commit: env.ghprbActualCommit || env.GIT_COMMIT || head({env, cwd}),
|
||||
branch: isPr ? env.ghprbTargetBranch || env.gitlabTargetBranch : localBranch,
|
||||
build: env.BUILD_NUMBER,
|
||||
buildUrl: env.BUILD_URL,
|
||||
root: env.WORKSPACE,
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: isPr ? env.ghprbSourceBranch || env.gitlabSourceBranch || localBranch : undefined,
|
||||
};
|
||||
},
|
||||
};
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// https://docs.netlify.com/configure-builds/environment-variables/#netlify-configuration-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return env.NETLIFY === 'true';
|
||||
},
|
||||
configuration({env}) {
|
||||
const isPr = env.PULL_REQUEST === 'true';
|
||||
|
||||
return {
|
||||
name: 'Netlify',
|
||||
service: 'netlify',
|
||||
commit: env.COMMIT_REF,
|
||||
build: env.DEPLOY_ID,
|
||||
buildUrl: `https://app.netlify.com/sites/${env.SITE_NAME}/deploys/${env.DEPLOY_ID}`,
|
||||
branch: isPr ? undefined : env.HEAD,
|
||||
pr: env.REVIEW_ID,
|
||||
isPr,
|
||||
prBranch: isPr ? env.HEAD : undefined,
|
||||
slug: env.REPOSITORY_URL.match(/[^/:]+\/[^/]+?$/)[0],
|
||||
root: env.PWD,
|
||||
};
|
||||
},
|
||||
};
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// https://puppet.com/docs/pipelines-for-apps/enterprise/environment-variable.html
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.DISTELLI_APPNAME);
|
||||
},
|
||||
configuration({env}) {
|
||||
return {
|
||||
name: 'Puppet',
|
||||
service: 'puppet',
|
||||
build: env.DISTELLI_BUILDNUM,
|
||||
buildUrl: env.DISTELLI_RELEASE,
|
||||
commit: env.DISTELLI_RELREVISION,
|
||||
branch: env.DISTELLI_RELBRANCH,
|
||||
root: env.DISTELLI_INSTALLHOME,
|
||||
};
|
||||
},
|
||||
};
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// https://sail.ci/docs/environment-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.SAILCI);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.SAIL_PULL_REQUEST_NUMBER;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Sail CI',
|
||||
service: 'sail',
|
||||
commit: env.SAIL_COMMIT_SHA,
|
||||
branch: isPr ? undefined : env.SAIL_COMMIT_BRANCH,
|
||||
pr,
|
||||
isPr,
|
||||
slug: `${env.SAIL_REPO_OWNER}/${env.SAIL_REPO_NAME}`,
|
||||
root: env.SAIL_CLONE_DIR,
|
||||
};
|
||||
},
|
||||
};
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// https://scrutinizer-ci.com/docs/build/environment-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.SCRUTINIZER);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.SCRUTINIZER_PR_NUMBER;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Scrutinizer',
|
||||
service: 'scrutinizer',
|
||||
commit: env.SCRUTINIZER_SHA1,
|
||||
build: env.SCRUTINIZER_INSPECTION_UUID,
|
||||
branch: env.SCRUTINIZER_BRANCH,
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: env.SCRUTINIZER_PR_SOURCE_BRANCH,
|
||||
};
|
||||
},
|
||||
};
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
const {head} = require('../lib/git.js');
|
||||
|
||||
// 1.0: https://semaphoreci.com/docs/available-environment-variables.html
|
||||
// 2.0: https://docs.semaphoreci.com/article/12-environment-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.SEMAPHORE);
|
||||
},
|
||||
configuration({env, cwd}) {
|
||||
const pr = env.SEMAPHORE_GIT_PR_NUMBER || env.PULL_REQUEST_NUMBER;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Semaphore',
|
||||
service: 'semaphore',
|
||||
commit: env.SEMAPHORE_GIT_SHA || head({env, cwd}),
|
||||
tag: env.SEMAPHORE_GIT_TAG_NAME,
|
||||
build: env.SEMAPHORE_JOB_ID || env.SEMAPHORE_BUILD_NUMBER,
|
||||
branch: env.SEMAPHORE_GIT_BRANCH || (isPr ? undefined : env.BRANCH_NAME),
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: env.SEMAPHORE_GIT_PR_BRANCH || (isPr ? env.BRANCH_NAME : undefined),
|
||||
slug: env.SEMAPHORE_GIT_REPO_SLUG || env.SEMAPHORE_REPO_SLUG,
|
||||
root: env.SEMAPHORE_GIT_DIR || env.SEMAPHORE_PROJECT_DIR,
|
||||
};
|
||||
},
|
||||
};
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// http://docs.shippable.com/ci/env-vars/#stdEnv
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.SHIPPABLE);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.IS_PULL_REQUEST === 'true' ? env.PULL_REQUEST : undefined;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Shippable',
|
||||
service: 'shippable',
|
||||
commit: env.COMMIT,
|
||||
tag: env.GIT_TAG_NAME,
|
||||
build: env.BUILD_NUMBER,
|
||||
buildUrl: env.BUILD_URL,
|
||||
branch: isPr ? env.BASE_BRANCH : env.BRANCH,
|
||||
job: env.JOB_NUMBER,
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: isPr ? env.HEAD_BRANCH : undefined,
|
||||
slug: env.SHIPPABLE_REPO_SLUG,
|
||||
root: env.SHIPPABLE_BUILD_DIR,
|
||||
};
|
||||
},
|
||||
};
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters
|
||||
|
||||
const javaProperties = require('java-properties');
|
||||
const fromEntries = require('fromentries');
|
||||
|
||||
const {branch} = require('../lib/git.js');
|
||||
|
||||
const PROPERTIES_MAPPING = {root: 'teamcity.build.workingDir', branch: 'teamcity.build.branch'};
|
||||
|
||||
const safeReadProperties = (filePath) => {
|
||||
try {
|
||||
return javaProperties.of(filePath);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
const getProperties = ({env, cwd}) => {
|
||||
const buildProperties = env.TEAMCITY_BUILD_PROPERTIES_FILE
|
||||
? safeReadProperties(env.TEAMCITY_BUILD_PROPERTIES_FILE)
|
||||
: undefined;
|
||||
const configFile = buildProperties ? buildProperties.get('teamcity.configuration.properties.file') : undefined;
|
||||
const configProperties = configFile ? safeReadProperties(configFile) : configFile;
|
||||
|
||||
return fromEntries(
|
||||
Object.keys(PROPERTIES_MAPPING).map((key) => [
|
||||
key,
|
||||
(buildProperties ? buildProperties.get(PROPERTIES_MAPPING[key]) : undefined) ||
|
||||
(configProperties ? configProperties.get(PROPERTIES_MAPPING[key]) : undefined) ||
|
||||
(key === 'branch' ? branch({env, cwd}) : undefined),
|
||||
])
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.TEAMCITY_VERSION);
|
||||
},
|
||||
configuration({env, cwd}) {
|
||||
return {
|
||||
name: 'TeamCity',
|
||||
service: 'teamcity',
|
||||
commit: env.BUILD_VCS_NUMBER,
|
||||
build: env.BUILD_NUMBER,
|
||||
slug: env.TEAMCITY_BUILDCONF_NAME,
|
||||
...getProperties({env, cwd}),
|
||||
};
|
||||
},
|
||||
};
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// https://docs.travis-ci.com/user/environment-variables#default-environment-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.TRAVIS);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.TRAVIS_PULL_REQUEST === 'false' ? undefined : env.TRAVIS_PULL_REQUEST;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Travis CI',
|
||||
service: 'travis',
|
||||
commit: env.TRAVIS_COMMIT,
|
||||
tag: env.TRAVIS_TAG,
|
||||
build: env.TRAVIS_BUILD_NUMBER,
|
||||
buildUrl: env.TRAVIS_BUILD_WEB_URL,
|
||||
branch: env.TRAVIS_BRANCH,
|
||||
job: env.TRAVIS_JOB_NUMBER,
|
||||
jobUrl: env.TRAVIS_JOB_WEB_URL,
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: env.TRAVIS_PULL_REQUEST_BRANCH,
|
||||
slug: env.TRAVIS_REPO_SLUG,
|
||||
root: env.TRAVIS_BUILD_DIR,
|
||||
};
|
||||
},
|
||||
};
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// https://go-vela.github.io/docs/reference/environment/variables/
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.VELA);
|
||||
},
|
||||
configuration({env}) {
|
||||
const isPr = env.VELA_BUILD_EVENT === 'pull_request';
|
||||
|
||||
return {
|
||||
name: 'Vela',
|
||||
service: 'vela',
|
||||
branch: isPr ? env.VELA_PULL_REQUEST_TARGET : env.VELA_BUILD_BRANCH,
|
||||
commit: env.VELA_BUILD_COMMIT,
|
||||
tag: env.VELA_BUILD_TAG,
|
||||
build: env.VELA_BUILD_NUMBER,
|
||||
buildUrl: env.VELA_BUILD_LINK,
|
||||
job: undefined,
|
||||
jobUrl: undefined,
|
||||
isPr,
|
||||
pr: env.VELA_BUILD_PULL_REQUEST,
|
||||
prBranch: env.VELA_PULL_REQUEST_SOURCE,
|
||||
slug: env.VELA_REPO_FULL_NAME,
|
||||
root: env.VELA_BUILD_WORKSPACE,
|
||||
};
|
||||
},
|
||||
};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// https://vercel.com/docs/environment-variables
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.VERCEL) || Boolean(env.NOW_GITHUB_DEPLOYMENT);
|
||||
},
|
||||
configuration({env}) {
|
||||
const name = 'Vercel';
|
||||
const service = 'vercel';
|
||||
|
||||
if (env.VERCEL) {
|
||||
return {
|
||||
name,
|
||||
service,
|
||||
commit: env.VERCEL_GIT_COMMIT_SHA,
|
||||
branch: env.VERCEL_GIT_COMMIT_REF,
|
||||
slug: `${env.VERCEL_GIT_REPO_OWNER}/${env.VERCEL_GIT_REPO_SLUG}`,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
name,
|
||||
service,
|
||||
commit: env.NOW_GITHUB_COMMIT_SHA,
|
||||
branch: env.NOW_GITHUB_COMMIT_REF,
|
||||
slug: `${env.NOW_GITHUB_ORG}/${env.NOW_GITHUB_REPO}`,
|
||||
};
|
||||
},
|
||||
};
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// https://docs.microsoft.com/en-us/vsts/pipelines/build/variables
|
||||
// The docs indicate that SYSTEM_PULLREQUEST_SOURCEBRANCH and SYSTEM_PULLREQUEST_TARGETBRANCH are in the long format (e.g `refs/heads/master`) however tests show they are both in the short format (e.g. `master`)
|
||||
const {parseBranch} = require('../lib/utils.js');
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.BUILD_BUILDURI);
|
||||
},
|
||||
configuration({env}) {
|
||||
const pr = env.SYSTEM_PULLREQUEST_PULLREQUESTID;
|
||||
const isPr = Boolean(pr);
|
||||
|
||||
return {
|
||||
name: 'Visual Studio Team Services',
|
||||
service: 'vsts',
|
||||
commit: env.BUILD_SOURCEVERSION,
|
||||
build: env.BUILD_BUILDNUMBER,
|
||||
branch: parseBranch(isPr ? env.SYSTEM_PULLREQUEST_TARGETBRANCH : env.BUILD_SOURCEBRANCH),
|
||||
pr,
|
||||
isPr,
|
||||
prBranch: parseBranch(isPr ? env.SYSTEM_PULLREQUEST_SOURCEBRANCH : undefined),
|
||||
root: env.BUILD_REPOSITORY_LOCALPATH,
|
||||
};
|
||||
},
|
||||
};
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// http://devcenter.wercker.com/docs/environment-variables/available-env-vars#hs_cos_wrapper_name
|
||||
|
||||
module.exports = {
|
||||
detect({env}) {
|
||||
return Boolean(env.WERCKER_MAIN_PIPELINE_STARTED);
|
||||
},
|
||||
configuration({env}) {
|
||||
return {
|
||||
name: 'Wercker',
|
||||
service: 'wercker',
|
||||
commit: env.WERCKER_GIT_COMMIT,
|
||||
build: env.WERCKER_MAIN_PIPELINE_STARTED,
|
||||
buildUrl: env.WERCKER_RUN_URL,
|
||||
branch: env.WERCKER_GIT_BRANCH,
|
||||
slug: `${env.WERCKER_GIT_OWNER}/${env.WERCKER_GIT_REPOSITORY}`,
|
||||
root: env.WERCKER_ROOT,
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user