Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
feat(services): add azure pipelines (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang authored and eddiemoore committed Dec 12, 2018
1 parent 023d204 commit e427d90
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/detect.js
Expand Up @@ -2,6 +2,7 @@ var services = {
travis: require('./services/travis'),
circle: require('./services/circle'),
buildkite: require('./services/buildkite'),
azurePipelines: require('./services/azurePipelines'),
codeship: require('./services/codeship'),
drone: require('./services/drone'),
appveyor: require('./services/appveyor'),
Expand Down
23 changes: 23 additions & 0 deletions lib/services/azurePipelines.js
@@ -0,0 +1,23 @@
module.exports = {
detect: function() {
return !!process.env.TF_BUILD
},

configuration: function() {
console.log(' Azure Pipelines CI Detected')
return {
service: 'azure_pipelines',
commit: process.env.BUILD_SOURCEVERSION,
branch: process.env.BUILD_SOURCEBRANCH,
pr: process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER,
job: process.env.SYSTEM_JOBID,
build: process.env.BUILD_BUILDID,
build_url:
process.env.SYSTEM_TEAMFOUNDATIONSERVERURI +
process.env.SYSTEM_TEAMPROJECT +
'/_build/results?buildId=' +
process.env.BUILD_BUILDID,
slug: process.env.BUILD_REPOSITORY_ID,
}
},
}
31 changes: 31 additions & 0 deletions test/services/azure-pipelines.js
@@ -0,0 +1,31 @@
var azurePipelines = require('../../lib/services/azurePipelines')

describe('Azure Pipelines CI Provider', function() {
it('can detect azure pipelines', function() {
process.env.TF_BUILD = '1'
expect(azurePipelines.detect()).to.be(true)
})

it('can get azure pipelines env info', function() {
process.env.BUILD_SOURCEBRANCH = 'master'
process.env.SYSTEM_JOBID = '92a2fa25-f940-5df6-a185-81eb9ae2031d'
process.env.BUILD_BUILDID = '1'
process.env.SYSTEM_TEAMFOUNDATIONSERVERURI =
'https://dev.azure.com/codecov/'
process.env.SYSTEM_TEAMPROJECT = 'repo'
process.env.BUILD_SOURCEVERSION = '743b04806ea677403aa2ff26c6bdeb85005de658'
process.env.BUILD_REPOSITORY_ID = 'owner/repo'
process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER = '1234'

expect(azurePipelines.configuration()).to.eql({
service: 'azure_pipelines',
build: '1',
build_url: 'https://dev.azure.com/codecov/repo/_build/results?buildId=1',
job: '92a2fa25-f940-5df6-a185-81eb9ae2031d',
commit: '743b04806ea677403aa2ff26c6bdeb85005de658',
pr: '1234',
branch: 'master',
slug: 'owner/repo',
})
})
})

0 comments on commit e427d90

Please sign in to comment.