Skip to content

Commit

Permalink
feat: add buildkite to ci-services (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning authored and janl committed Oct 24, 2017
1 parent f03d1f4 commit 26439f2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ci-services/buildkite.js
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions ci-services/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 7 additions & 0 deletions lib/git-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]}`
)
}
}

0 comments on commit 26439f2

Please sign in to comment.