diff --git a/ci-services/buildkite.js b/ci-services/buildkite.js new file mode 100644 index 00000000..6ea15897 --- /dev/null +++ b/ci-services/buildkite.js @@ -0,0 +1,13 @@ +'use strict' + +const gitHelpers = require('../lib/git-helpers') + +const env = process.env + +module.exports = { + repoSlug: gitHelpers.getRepoSlug(env.BUILDKITE_REPO), + branchName: env.BUILDKITE_BRANCH, + firstPush: gitHelpers.getNumberOfCommitsOnBranch(env.BUILDKITE_BRANCH) === 1, + correctBuild: env.BUILDKITE_PULL_REQUEST === 'false', + uploadBuild: true +} diff --git a/ci-services/tests.js b/ci-services/tests.js index 095ce72e..65d33724 100644 --- a/ci-services/tests.js +++ b/ci-services/tests.js @@ -3,6 +3,7 @@ const env = process.env module.exports = { + buildkite: () => env.BUILDKITE === 'true', circleci: () => env.CIRCLECI === 'true', jenkins: () => env.JENKINS_URL !== undefined, travis: () => env.TRAVIS === 'true', diff --git a/lib/git-helpers.js b/lib/git-helpers.js index afcede59..49636219 100644 --- a/lib/git-helpers.js +++ b/lib/git-helpers.js @@ -13,5 +13,12 @@ module.exports = { `git log ${refArgument} --oneline --not ${notArgument} | wc -l` ).toString() ) + }, + getRepoSlug: function getRepoSlug (githubUrl) { + var ghRegex = /\S+[:|/](\w+(?:[-]\w+)*)\/(\w+(?:[-]\w+)*)/g + var parsed = ghRegex.exec(githubUrl) + return ( + `${parsed[1]}/${parsed[2]}` + ) } }