Skip to content

Commit

Permalink
address #7 and #22
Browse files Browse the repository at this point in the history
  • Loading branch information
vtbassmatt committed Sep 26, 2018
1 parent cd2d97c commit f01fe13
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ exports.isCI = !!(
env.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
env.BUILD_NUMBER || // Jenkins, TeamCity
env.RUN_ID || // TaskCluster, dsari
// Azure Pipelines
(env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI && env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI.startsWith('https://dev.azure.com')) ||
exports.name ||
false
)
Expand Down
36 changes: 36 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,42 @@ test('AppVeyor - Not PR', function (t) {
t.end()
})

test('Azure Pipelines - PR', function (t) {
process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI = 'https://dev.azure.com/Contoso'
process.env.SYSTEM_PULLREQUEST_PULLREQUESTID = '42'

clearRequire('./')
var ci = require('./')

t.equal(ci.isCI, true)
t.equal(ci.isPR, true)
t.equal(ci.name, 'Azure Pipelines')
t.equal(ci.AZURE_PIPELINES, true)
assertVendorConstants('AZURE_PIPELINES', ci, t)

delete process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI
delete process.env.SYSTEM_PULLREQUEST_PULLREQUESTID

t.end()
})

test('Azure Pipelines - Not PR', function (t) {
process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI = 'https://dev.azure.com/Contoso'

clearRequire('./')
var ci = require('./')

t.equal(ci.isCI, true)
t.equal(ci.isPR, false)
t.equal(ci.name, 'Azure Pipelines')
t.equal(ci.AZURE_PIPELINES, true)
assertVendorConstants('AZURE_PIPELINES', ci, t)

delete process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI

t.end()
})

test('Buildkite - PR', function (t) {
process.env.BUILDKITE = 'true'
process.env.BUILDKITE_PULL_REQUEST = '42'
Expand Down
6 changes: 6 additions & 0 deletions vendors.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"env": "APPVEYOR",
"pr": "APPVEYOR_PULL_REQUEST_NUMBER"
},
{
"name": "Azure Pipelines",
"constant": "AZURE_PIPELINES",
"env": "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI",
"pr": "SYSTEM_PULLREQUEST_PULLREQUESTID"
},
{
"name": "Bamboo",
"constant": "BAMBOO",
Expand Down

0 comments on commit f01fe13

Please sign in to comment.