2017-05-28 00:38:50 +02:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
var env = process.env
|
|
|
|
|
|
|
|
var vendors = [
|
|
|
|
// Constant, Name, Envs
|
|
|
|
['TRAVIS', 'Travis CI', 'TRAVIS'],
|
|
|
|
['CIRCLE', 'CircleCI', 'CIRCLECI'],
|
|
|
|
['GITLAB', 'GitLab CI', 'GITLAB_CI'],
|
|
|
|
['APPVEYOR', 'AppVeyor', 'APPVEYOR'],
|
|
|
|
['CODESHIP', 'Codeship', {CI_NAME: 'codeship'}],
|
|
|
|
['DRONE', 'Drone', 'DRONE'],
|
|
|
|
['MAGNUM', 'Magnum CI', 'MAGNUM'],
|
|
|
|
['SEMAPHORE', 'Semaphore', 'SEMAPHORE'],
|
2017-12-27 19:33:54 +01:00
|
|
|
['JENKINS', 'Jenkins', 'JENKINS_URL', 'BUILD_ID'],
|
2017-05-28 00:38:50 +02:00
|
|
|
['BAMBOO', 'Bamboo', 'bamboo_planKey'],
|
|
|
|
['TFS', 'Team Foundation Server', 'TF_BUILD'],
|
|
|
|
['TEAMCITY', 'TeamCity', 'TEAMCITY_VERSION'],
|
|
|
|
['BUILDKITE', 'Buildkite', 'BUILDKITE'],
|
|
|
|
['HUDSON', 'Hudsun', 'HUDSON_URL'],
|
|
|
|
['TASKCLUSTER', 'TaskCluster', 'TASK_ID', 'RUN_ID'],
|
|
|
|
['GOCD', 'GoCD', 'GO_PIPELINE_LABEL'],
|
2017-12-27 19:33:54 +01:00
|
|
|
['BITBUCKET', 'Bitbucket Pipelines', 'BITBUCKET_COMMIT'],
|
|
|
|
['CODEBUILD', 'AWS CodeBuild', 'CODEBUILD_BUILD_ARN']
|
2017-05-28 00:38:50 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
exports.name = null
|
|
|
|
|
|
|
|
vendors.forEach(function (vendor) {
|
|
|
|
var constant = vendor.shift()
|
|
|
|
var name = vendor.shift()
|
|
|
|
var isCI = vendor.every(function (obj) {
|
|
|
|
if (typeof obj === 'string') return !!env[obj]
|
|
|
|
return Object.keys(obj).every(function (k) {
|
|
|
|
return env[k] === obj[k]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
exports[constant] = isCI
|
|
|
|
if (isCI) exports.name = name
|
|
|
|
})
|
|
|
|
|
|
|
|
exports.isCI = !!(
|
|
|
|
env.CI || // Travis CI, CircleCI, Gitlab CI, Appveyor, CodeShip
|
|
|
|
env.CONTINUOUS_INTEGRATION || // Travis CI
|
|
|
|
env.BUILD_NUMBER || // Jenkins, TeamCity
|
|
|
|
exports.name ||
|
|
|
|
false
|
|
|
|
)
|