Skip to content

Commit

Permalink
feat: add Bitrise
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Jan 27, 2018
1 parent 24d861b commit 9d2fc5a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const {isCi, service, commit, build, branch, job, pr, isPr, slug, root} = envCi(
|-----------------------------------------------------------------------------------------------------------|:-----------:|:------:|:--------:|:-------:|:--------:|:-----:|:----:|:------:|:------:|:------:|
| [AppVeyor]( https://www.appveyor.com/docs/environment-variables) | `appveyor` ||||||||||
| [Bamboo](https://confluence.atlassian.com/bamboo/bamboo-variables-289277087.html) | `bamboo` ||||||||||
| [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` ||||||||||
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const git = require('./lib/git');
const services = {
appveyor: require('./lib/appveyor'),
bamboo: require('./lib/bamboo'),
bitrise: require('./lib/bitrise'),
buildkite: require('./lib/buildkite'),
circleci: require('./lib/circleci'),
codeship: require('./lib/codeship'),
Expand Down
18 changes: 18 additions & 0 deletions lib/bitrise.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// http://devcenter.bitrise.io/faq/available-environment-variables/

module.exports = {
detect() {
return Boolean(process.env.BITRISE_IO);
},
configuration() {
return {
service: 'bitrise',
commit: process.env.BITRISE_GIT_COMMIT,
build: process.env.BITRISE_BUILD_NUMBER,
branch: process.env.BITRISE_GIT_BRANCH,
pr: process.env.BITRISE_PULL_REQUEST === 'false' ? undefined : process.env.BITRISE_PULL_REQUEST,
isPr: process.env.BITRISE_PULL_REQUEST && process.env.BITRISE_PULL_REQUEST !== 'false',
slug: process.env.BITRISE_APP_SLUG,
};
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"keywords": [
"appveyor",
"bamboo",
"bitrise",
"buildkite",
"ci",
"circle",
Expand Down
40 changes: 40 additions & 0 deletions test/bitrise.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import test from 'ava';
import bitrise from '../lib/bitrise';

test('Push', t => {
process.env.BITRISE_IO = 'true';
process.env.BITRISE_GIT_COMMIT = '5678';
process.env.BITRISE_BUILD_NUMBER = '91011';
process.env.BITRISE_GIT_BRANCH = 'master';
process.env.BITRISE_PULL_REQUEST = 'false';
process.env.BITRISE_APP_SLUG = 'owner/repo';

t.deepEqual(bitrise.configuration(), {
service: 'bitrise',
commit: '5678',
build: '91011',
branch: 'master',
pr: undefined,
isPr: false,
slug: 'owner/repo',
});
});

test('PR', t => {
process.env.BITRISE_IO = 'true';
process.env.BITRISE_GIT_COMMIT = '5678';
process.env.BITRISE_BUILD_NUMBER = '91011';
process.env.BITRISE_GIT_BRANCH = 'master';
process.env.BITRISE_PULL_REQUEST = '10';
process.env.BITRISE_APP_SLUG = 'owner/repo';

t.deepEqual(bitrise.configuration(), {
service: 'bitrise',
commit: '5678',
build: '91011',
branch: 'master',
pr: '10',
isPr: true,
slug: 'owner/repo',
});
});

0 comments on commit 9d2fc5a

Please sign in to comment.