From bedc9759c7cf037fd4732aff1a2c695c71ce72bc Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Sat, 3 Feb 2018 23:38:38 -0500 Subject: [PATCH] feat: add `buildUrl` and `jobUrl` properties --- README.md | 58 ++++++++++++++++++++++-------------------- lib/appveyor.js | 6 +++++ lib/bamboo.js | 1 + lib/bitrise.js | 3 ++- lib/buildkite.js | 1 + lib/circleci.js | 3 ++- lib/codeship.js | 1 + lib/gitlab.js | 2 ++ lib/jenkins.js | 1 + lib/shippable.js | 1 + lib/wercker.js | 1 + test/appveyor.test.js | 9 +++++++ test/bamboo.test.js | 18 +++++++------ test/bitrise.test.js | 4 +++ test/buildkite.test.js | 3 +++ test/circleci.test.js | 7 +++-- test/codeship.test.js | 2 ++ test/gitlab.test.js | 9 +++++-- test/jenkins.test.js | 6 +++++ test/shippable.test.js | 4 +++ test/wercker.test.js | 2 ++ 21 files changed, 100 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index b2e4cf3..afef429 100644 --- a/README.md +++ b/README.md @@ -24,36 +24,38 @@ const {isCi, service, commit, build, branch, job, pr, isPr, slug, root} = envCi( ## Variables -| Variable | Description | -|-----------|-----------------------------------------------------------------------------------| -| `isCi` | `true` is running on a CI, `false` otherwise | -| `service` | CI service name | -| `commit` | Commit sha that triggered the CI build | -| `build` | CI service build number | -| `branch` | Git branch being built or targeted by a pull request | -| `job` | CI service job number | -| `pr` | Pull Request number | -| `isPr` | `true` is the build has been triggered by a Pull Request, `false` otherwise | -| `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 | +| Variable | Description | +|------------|-----------------------------------------------------------------------------------| +| `isCi` | `true` is running on a CI, `false` otherwise | +| `service` | CI service name | +| `commit` | Commit sha that triggered the CI build | +| `build` | CI service build number | +| `buildUrl` | Link to the CI service build | +| `branch` | Git branch being built or targeted by a pull request | +| `job` | CI service job number | +| `jobUrl` | Link to the CI service job | +| `pr` | Pull Request number | +| `isPr` | `true` is the build has been triggered by a Pull Request, `false` otherwise | +| `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 | ## Supported CI -| CI Service | `service` | `isCi` | `commit` | `build` | `branch` | `job` | `pr` | `isPr` | `slug` | `root` | -|-----------------------------------------------------------------------------------------------------------|:-----------:|:------:|:--------:|:-------:|:--------:|:-----:|:----:|:------:|:------:|:------:| -| [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` | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | -| [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 | `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` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | +| [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` | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | 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 9eb11c9..7e423ae 100644 --- a/lib/appveyor.js +++ b/lib/appveyor.js @@ -9,8 +9,14 @@ module.exports = { service: 'appveyor', commit: process.env.APPVEYOR_REPO_COMMIT, build: process.env.APPVEYOR_BUILD_NUMBER, + buildUrl: `https://ci.appveyor.com/project/${process.env.APPVEYOR_PROJECT_SLUG}/build/${ + process.env.APPVEYOR_BUILD_VERSION + }`, branch: process.env.APPVEYOR_REPO_BRANCH, job: process.env.APPVEYOR_JOB_NUMBER, + jobUrl: `https://ci.appveyor.com/project/${process.env.APPVEYOR_PROJECT_SLUG}/build/job/${ + process.env.APPVEYOR_JOB_ID + }`, pr: process.env.APPVEYOR_PULL_REQUEST_NUMBER, isPr: Boolean(process.env.APPVEYOR_PULL_REQUEST_NUMBER), slug: process.env.APPVEYOR_REPO_NAME, diff --git a/lib/bamboo.js b/lib/bamboo.js index b2e8c47..0f65f8b 100644 --- a/lib/bamboo.js +++ b/lib/bamboo.js @@ -11,6 +11,7 @@ module.exports = { /* eslint-disable camelcase */ commit: process.env.bamboo_planRepository_1_revision, build: process.env.bamboo_buildNumber, + buildUrl: process.env.bamboo_buildResultsUrl, branch: process.env.bamboo_planRepository_1_branchName, job: process.env.bamboo_buildKey, root: process.env.bamboo_build_working_directory, diff --git a/lib/bitrise.js b/lib/bitrise.js index 246b72c..ce62889 100644 --- a/lib/bitrise.js +++ b/lib/bitrise.js @@ -1,4 +1,4 @@ -// http://devcenter.bitrise.io/faq/available-environment-variables/ +// http://devcenter.bitrise.io/faq/available-environment-variables module.exports = { detect() { @@ -9,6 +9,7 @@ module.exports = { service: 'bitrise', commit: process.env.BITRISE_GIT_COMMIT, build: process.env.BITRISE_BUILD_NUMBER, + buildUrl: process.env.BITRISE_BUILD_URL, 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', diff --git a/lib/buildkite.js b/lib/buildkite.js index 116541c..0aa24dc 100644 --- a/lib/buildkite.js +++ b/lib/buildkite.js @@ -8,6 +8,7 @@ module.exports = { return { service: 'buildkite', build: process.env.BUILDKITE_BUILD_NUMBER, + buildUrl: process.env.BUILDKITE_BUILD_URL, commit: process.env.BUILDKITE_COMMIT, branch: process.env.BUILDKITE_BRANCH, slug: `${process.env.BUILDKITE_ORGANIZATION_SLUG}/${process.env.BUILDKITE_PROJECT_SLUG}`, diff --git a/lib/circleci.js b/lib/circleci.js index b9f752f..b7936d7 100644 --- a/lib/circleci.js +++ b/lib/circleci.js @@ -7,7 +7,8 @@ module.exports = { configuration() { return { service: 'circleci', - build: `${process.env.CIRCLE_BUILD_NUM}.${process.env.CIRCLE_NODE_INDEX}`, + build: process.env.CIRCLE_BUILD_NUM, + buildUrl: process.env.CIRCLE_BUILD_URL, job: `${process.env.CIRCLE_BUILD_NUM}.${process.env.CIRCLE_NODE_INDEX}`, commit: process.env.CIRCLE_SHA1, branch: process.env.CIRCLE_BRANCH, diff --git a/lib/codeship.js b/lib/codeship.js index 23d8621..6d4259f 100644 --- a/lib/codeship.js +++ b/lib/codeship.js @@ -8,6 +8,7 @@ module.exports = { return { service: 'codeship', build: process.env.CI_BUILD_NUMBER, + buildUrl: process.env.CI_BUILD_URL, commit: process.env.CI_COMMIT_ID, branch: process.env.CI_BRANCH, slug: process.env.CI_REPO_NAME, diff --git a/lib/gitlab.js b/lib/gitlab.js index a6e5718..b3dcc17 100644 --- a/lib/gitlab.js +++ b/lib/gitlab.js @@ -9,7 +9,9 @@ module.exports = { service: 'gitlab', commit: process.env.CI_COMMIT_SHA, build: process.env.CI_JOB_NAME, + buildUrl: `${process.env.CI_PROJECT_URL}/pipelines/${process.env.CI_PIPELINE_ID}`, job: process.env.CI_JOB_STAGE, + jobUrl: `${process.env.CI_PROJECT_URL}/-/jobs/${process.env.CI_JOB_ID}`, branch: process.env.CI_COMMIT_REF_NAME, slug: process.env.CI_PROJECT_PATH, root: process.env.CI_PROJECT_DIR, diff --git a/lib/jenkins.js b/lib/jenkins.js index 84dda50..5af5408 100644 --- a/lib/jenkins.js +++ b/lib/jenkins.js @@ -12,6 +12,7 @@ module.exports = { commit: process.env.ghprbActualCommit || process.env.GIT_COMMIT || git.head(), branch: process.env.ghprbSourceBranch || process.env.GIT_BRANCH || process.env.BRANCH_NAME, build: process.env.BUILD_NUMBER, + buildUrl: process.env.BUILD_URL, root: process.env.WORKSPACE, pr: process.env.ghprbPullId || process.env.CHANGE_ID, isPr: Boolean(process.env.ghprbPullId || process.env.CHANGE_ID), diff --git a/lib/shippable.js b/lib/shippable.js index 300c6da..ec1afd8 100644 --- a/lib/shippable.js +++ b/lib/shippable.js @@ -9,6 +9,7 @@ module.exports = { service: 'shippable', commit: process.env.COMMIT, build: process.env.BUILD_NUMBER, + buildUrl: process.env.BUILD_URL, branch: process.env.BASE_BRANCH || process.env.BRANCH, job: process.env.JOB_NUMBER, pr: process.env.PULL_REQUEST === 'false' ? undefined : process.env.PULL_REQUEST, diff --git a/lib/wercker.js b/lib/wercker.js index 17bc983..703c8d3 100644 --- a/lib/wercker.js +++ b/lib/wercker.js @@ -9,6 +9,7 @@ module.exports = { service: 'wercker', commit: process.env.WERCKER_GIT_COMMIT, build: process.env.WERCKER_MAIN_PIPELINE_STARTED, + buildUrl: process.env.WERCKER_RUN_URL, branch: process.env.WERCKER_GIT_BRANCH, slug: `${process.env.WERCKER_GIT_OWNER}/${process.env.WERCKER_GIT_REPOSITORY}`, root: process.env.WERCKER_ROOT, diff --git a/test/appveyor.test.js b/test/appveyor.test.js index 2672e3a..450cf8e 100644 --- a/test/appveyor.test.js +++ b/test/appveyor.test.js @@ -4,10 +4,13 @@ import appveyor from '../lib/appveyor'; test('Push', t => { process.env.APPVEYOR = 'true'; process.env.APPVEYOR_JOB_NUMBER = '1234'; + process.env.APPVEYOR_JOB_ID = 'job_id'; + process.env.APPVEYOR_BUILD_VERSION = '100'; process.env.APPVEYOR_REPO_COMMIT = '5678'; process.env.APPVEYOR_BUILD_NUMBER = '91011'; process.env.APPVEYOR_REPO_BRANCH = 'master'; process.env.APPVEYOR_REPO_NAME = 'owner/repo'; + process.env.APPVEYOR_PROJECT_SLUG = 'owner/repo'; process.env.APPVEYOR_BUILD_FOLDER = '/'; delete process.env.APPVEYOR_PULL_REQUEST_NUMBER; @@ -15,9 +18,11 @@ test('Push', t => { service: 'appveyor', commit: '5678', build: '91011', + buildUrl: 'https://ci.appveyor.com/project/owner/repo/build/100', branch: 'master', root: '/', job: '1234', + jobUrl: 'https://ci.appveyor.com/project/owner/repo/build/job/job_id', pr: undefined, isPr: false, slug: 'owner/repo', @@ -27,6 +32,8 @@ test('Push', t => { test('PR', t => { process.env.APPVEYOR = 'true'; process.env.APPVEYOR_JOB_NUMBER = '1234'; + process.env.APPVEYOR_JOB_ID = 'job_id'; + process.env.APPVEYOR_BUILD_VERSION = '100'; process.env.APPVEYOR_REPO_COMMIT = '5678'; process.env.APPVEYOR_BUILD_NUMBER = '91011'; process.env.APPVEYOR_REPO_NAME = 'owner/repo'; @@ -38,9 +45,11 @@ test('PR', t => { service: 'appveyor', commit: '5678', build: '91011', + buildUrl: 'https://ci.appveyor.com/project/owner/repo/build/100', branch: 'master', root: '/', job: '1234', + jobUrl: 'https://ci.appveyor.com/project/owner/repo/build/job/job_id', pr: '10', isPr: true, slug: 'owner/repo', diff --git a/test/bamboo.test.js b/test/bamboo.test.js index 140def9..d0505a7 100644 --- a/test/bamboo.test.js +++ b/test/bamboo.test.js @@ -3,19 +3,21 @@ import bamboo from '../lib/bamboo'; test('Push', t => { /* eslint-disable camelcase */ - process.env.bamboo_planRepository_1_revision = 'some commit hash'; - process.env.bamboo_buildNumber = 'some build number'; - process.env.bamboo_planRepository_1_branchName = 'some branch name'; - process.env.bamboo_buildKey = 'some job number'; + process.env.bamboo_buildKey = '1234'; + process.env.bamboo_planRepository_1_revision = '5678'; + process.env.bamboo_buildNumber = '91011'; + process.env.bamboo_planRepository_1_branchName = 'master'; process.env.bamboo_build_working_directory = '/some/working/dir'; + process.env.bamboo_buildResultsUrl = 'https://server.com/buildresult'; /* eslint-enable camelcase */ t.deepEqual(bamboo.configuration(), { service: 'bamboo', - commit: 'some commit hash', - build: 'some build number', - branch: 'some branch name', + commit: '5678', + build: '91011', + buildUrl: 'https://server.com/buildresult', + branch: 'master', + job: '1234', root: '/some/working/dir', - job: 'some job number', }); }); diff --git a/test/bitrise.test.js b/test/bitrise.test.js index 9e093df..f282fb9 100644 --- a/test/bitrise.test.js +++ b/test/bitrise.test.js @@ -5,6 +5,7 @@ test('Push', t => { process.env.BITRISE_IO = 'true'; process.env.BITRISE_GIT_COMMIT = '5678'; process.env.BITRISE_BUILD_NUMBER = '91011'; + process.env.BITRISE_BUILD_URL = 'https://server.com/buildresult'; process.env.BITRISE_GIT_BRANCH = 'master'; process.env.BITRISE_PULL_REQUEST = 'false'; process.env.BITRISE_APP_SLUG = 'owner/repo'; @@ -13,6 +14,7 @@ test('Push', t => { service: 'bitrise', commit: '5678', build: '91011', + buildUrl: 'https://server.com/buildresult', branch: 'master', pr: undefined, isPr: false, @@ -24,6 +26,7 @@ test('PR', t => { process.env.BITRISE_IO = 'true'; process.env.BITRISE_GIT_COMMIT = '5678'; process.env.BITRISE_BUILD_NUMBER = '91011'; + process.env.BITRISE_BUILD_URL = 'https://server.com/buildresult'; process.env.BITRISE_GIT_BRANCH = 'master'; process.env.BITRISE_PULL_REQUEST = '10'; process.env.BITRISE_APP_SLUG = 'owner/repo'; @@ -32,6 +35,7 @@ test('PR', t => { service: 'bitrise', commit: '5678', build: '91011', + buildUrl: 'https://server.com/buildresult', branch: 'master', pr: '10', isPr: true, diff --git a/test/buildkite.test.js b/test/buildkite.test.js index 634e19c..2477ad4 100644 --- a/test/buildkite.test.js +++ b/test/buildkite.test.js @@ -5,6 +5,7 @@ test('Push', t => { process.env.BUILDKITE = 'true'; process.env.BUILDKITE_COMMIT = '5678'; process.env.BUILDKITE_BUILD_NUMBER = '91011'; + process.env.BUILDKITE_BUILD_URL = 'https://server.com/buildresult'; process.env.BUILDKITE_BRANCH = 'master'; process.env.BUILDKITE_PULL_REQUEST = 'false'; process.env.BUILDKITE_BUILD_CHECKOUT_PATH = '/'; @@ -15,6 +16,7 @@ test('Push', t => { service: 'buildkite', commit: '5678', build: '91011', + buildUrl: 'https://server.com/buildresult', branch: 'master', root: '/', pr: undefined, @@ -37,6 +39,7 @@ test('PR', t => { service: 'buildkite', commit: '5678', build: '91011', + buildUrl: 'https://server.com/buildresult', branch: 'master', root: '/', pr: '10', diff --git a/test/circleci.test.js b/test/circleci.test.js index d9b1b10..86514c5 100644 --- a/test/circleci.test.js +++ b/test/circleci.test.js @@ -4,6 +4,7 @@ import circle from '../lib/circleci'; test('Push', t => { process.env.CIRCLECI = 'true'; process.env.CIRCLE_BUILD_NUM = '1234'; + process.env.CIRCLE_BUILD_URL = 'https://server.com/buildresult'; process.env.CIRCLE_SHA1 = '5678'; process.env.CIRCLE_BRANCH = 'master'; process.env.CIRCLE_NODE_INDEX = '1'; @@ -14,7 +15,8 @@ test('Push', t => { t.deepEqual(circle.configuration(), { service: 'circleci', commit: '5678', - build: '1234.1', + build: '1234', + buildUrl: 'https://server.com/buildresult', job: '1234.1', branch: 'master', pr: undefined, @@ -36,7 +38,8 @@ test('PR', t => { t.deepEqual(circle.configuration(), { service: 'circleci', commit: '5678', - build: '1234.1', + build: '1234', + buildUrl: 'https://server.com/buildresult', job: '1234.1', branch: 'pr_branch', pr: '10', diff --git a/test/codeship.test.js b/test/codeship.test.js index 211d715..8e1e44f 100644 --- a/test/codeship.test.js +++ b/test/codeship.test.js @@ -4,6 +4,7 @@ import codeship from '../lib/codeship'; test('Push', t => { process.env.CI_NAME = 'codeship'; process.env.CI_BUILD_NUMBER = '91011'; + process.env.CI_BUILD_URL = 'https://server.com/buildresult'; process.env.CI_COMMIT_ID = '5678'; process.env.CI_BRANCH = 'master'; process.env.CI_REPO_NAME = 'owner/repo'; @@ -12,6 +13,7 @@ test('Push', t => { service: 'codeship', commit: '5678', build: '91011', + buildUrl: 'https://server.com/buildresult', branch: 'master', slug: 'owner/repo', }); diff --git a/test/gitlab.test.js b/test/gitlab.test.js index d206f66..42c0763 100644 --- a/test/gitlab.test.js +++ b/test/gitlab.test.js @@ -4,8 +4,11 @@ import gitlab from '../lib/gitlab'; test('Push', t => { process.env.GITLAB_CI = 'true'; process.env.CI_COMMIT_SHA = '5678'; - process.env.CI_JOB_NAME = '91011'; + process.env.CI_JOB_NAME = 'job_name'; process.env.CI_JOB_STAGE = '1234'; + process.env.CI_PIPELINE_ID = '91011'; + process.env.CI_JOB_ID = '1213'; + process.env.CI_PROJECT_URL = 'https://gitlab.com/owner/repo'; process.env.CI_COMMIT_REF_NAME = 'master'; process.env.CI_PROJECT_PATH = 'owner/repo'; process.env.CI_PROJECT_DIR = '/'; @@ -13,10 +16,12 @@ test('Push', t => { t.deepEqual(gitlab.configuration(), { service: 'gitlab', commit: '5678', - build: '91011', + build: 'job_name', + buildUrl: 'https://gitlab.com/owner/repo/pipelines/91011', branch: 'master', root: '/', job: '1234', + jobUrl: 'https://gitlab.com/owner/repo/-/jobs/1213', slug: 'owner/repo', }); }); diff --git a/test/jenkins.test.js b/test/jenkins.test.js index 50e1473..26c97b2 100644 --- a/test/jenkins.test.js +++ b/test/jenkins.test.js @@ -6,6 +6,7 @@ test('Push', t => { process.env.GIT_COMMIT = '5678'; process.env.GIT_BRANCH = 'master'; process.env.BUILD_NUMBER = '91011'; + process.env.BUILD_URL = 'http://jenkins.jenkins.example/buildResult'; process.env.WORKSPACE = '/'; delete process.env.BRANCH_NAME; delete process.env.ghprbActualCommit; @@ -17,6 +18,7 @@ test('Push', t => { service: 'jenkins', commit: '5678', build: '91011', + buildUrl: 'http://jenkins.jenkins.example/buildResult', branch: 'master', root: '/', pr: undefined, @@ -29,6 +31,7 @@ test('PR', t => { process.env.GIT_COMMIT = '5678'; process.env.BRANCH_NAME = 'pr_branch'; process.env.BUILD_NUMBER = '91011'; + process.env.BUILD_URL = 'http://jenkins.jenkins.example/buildResult'; process.env.WORKSPACE = '/'; process.env.CHANGE_ID = '10'; delete process.env.GIT_BRANCH; @@ -40,6 +43,7 @@ test('PR', t => { service: 'jenkins', commit: '5678', build: '91011', + buildUrl: 'http://jenkins.jenkins.example/buildResult', branch: 'pr_branch', root: '/', pr: '10', @@ -52,6 +56,7 @@ test('PR (PR builder)', t => { process.env.ghprbActualCommit = '5678'; process.env.ghprbSourceBranch = 'pr_branch'; process.env.BUILD_NUMBER = '91011'; + process.env.BUILD_URL = 'http://jenkins.jenkins.example/buildResult'; process.env.WORKSPACE = '/'; process.env.ghprbPullId = '10'; delete process.env.GIT_BRANCH; @@ -63,6 +68,7 @@ test('PR (PR builder)', t => { service: 'jenkins', commit: '5678', build: '91011', + buildUrl: 'http://jenkins.jenkins.example/buildResult', branch: 'pr_branch', root: '/', pr: '10', diff --git a/test/shippable.test.js b/test/shippable.test.js index 9773ec8..4c1737f 100644 --- a/test/shippable.test.js +++ b/test/shippable.test.js @@ -6,6 +6,7 @@ test('Push', t => { process.env.JOB_NUMBER = '1234'; process.env.COMMIT = '5678'; process.env.BUILD_NUMBER = '91011'; + process.env.BUILD_URL = 'https://server.com/buildresult'; process.env.BRANCH = 'master'; process.env.PULL_REQUEST = 'false'; process.env.IS_PULL_REQUEST = 'false'; @@ -17,6 +18,7 @@ test('Push', t => { service: 'shippable', commit: '5678', build: '91011', + buildUrl: 'https://server.com/buildresult', branch: 'master', root: '/', job: '1234', @@ -31,6 +33,7 @@ test('PR', t => { process.env.JOB_NUMBER = '1234'; process.env.COMMIT = '5678'; process.env.BUILD_NUMBER = '91011'; + process.env.BUILD_URL = 'https://server.com/buildresult'; process.env.BASE_BRANCH = 'master'; process.env.PULL_REQUEST = '10'; process.env.IS_PULL_REQUEST = 'true'; @@ -42,6 +45,7 @@ test('PR', t => { service: 'shippable', commit: '5678', build: '91011', + buildUrl: 'https://server.com/buildresult', branch: 'master', root: '/', job: '1234', diff --git a/test/wercker.test.js b/test/wercker.test.js index ef6b50c..104136e 100644 --- a/test/wercker.test.js +++ b/test/wercker.test.js @@ -3,6 +3,7 @@ import wercker from '../lib/wercker'; test('Push', t => { process.env.WERCKER_MAIN_PIPELINE_STARTED = '123456'; + process.env.WERCKER_RUN_URL = 'https://server.com/buildresult'; process.env.WERCKER_GIT_COMMIT = '5678'; process.env.WERCKER_GIT_BRANCH = 'master'; process.env.WERCKER_ROOT = '/'; @@ -13,6 +14,7 @@ test('Push', t => { service: 'wercker', commit: '5678', build: '123456', + buildUrl: 'https://server.com/buildresult', branch: 'master', root: '/', slug: 'owner/repo',