-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci-provider.js
More file actions
57 lines (53 loc) · 1.66 KB
/
Copy pathci-provider.js
File metadata and controls
57 lines (53 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict'
const anyKey = (env, pattern) => Object.keys(env).some(key => pattern.test(key))
// The order matters when the variables of two providers are set: the first
// match wins. It is the order the Currents clients detect providers in.
const CI_PROVIDERS = [
['appveyor', env => env.APPVEYOR],
['azure', env => env.TF_BUILD && env.AZURE_HTTP_USER_AGENT],
['awsCodeBuild', env => anyKey(env, /^CODEBUILD_/)],
['bamboo', env => env.bamboo_buildNumber],
['bitbucket', env => env.BITBUCKET_BUILD_NUMBER],
['buildkite', env => env.BUILDKITE],
['circle', env => env.CIRCLECI],
['concourse', env => anyKey(env, /^CONCOURSE_/)],
['codeFresh', env => env.CF_BUILD_ID],
['drone', env => env.DRONE],
['githubActions', env => env.GITHUB_ACTIONS],
[
'gitlab',
env =>
env.GITLAB_CI ||
(env.CI_SERVER_NAME && /^GitLab/.test(env.CI_SERVER_NAME))
],
['goCD', env => env.GO_JOB_NAME],
[
'jenkins',
env =>
env.JENKINS_URL ||
env.JENKINS_HOME ||
env.JENKINS_VERSION ||
env.HUDSON_URL ||
env.HUDSON_HOME
],
[
'googleCloud',
env =>
(env.BUILD_ID && env.PROJECT_ID && env.PROJECT_NUMBER) ||
env.GCP_PROJECT ||
env.GCLOUD_PROJECT ||
env.GOOGLE_CLOUD_PROJECT
],
['semaphore', env => env.SEMAPHORE],
['teamcity', env => env.TEAMCITY_VERSION],
['travis', env => env.TRAVIS],
['netlify', env => env.NETLIFY]
]
/**
* Returns the name of the CI provider the process runs on, or null.
*/
function detectCiProvider (env = process.env) {
const found = CI_PROVIDERS.find(([, isProvider]) => isProvider(env))
return found ? found[0] : null
}
module.exports = { detectCiProvider }