Skip to content

Commit 9d19a9f

Browse files
fix: Capture env vars from AWS Code Build (#8159)
1 parent e0f587e commit 9d19a9f

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

packages/server/__snapshots__/cypress_spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
6060
6161
- appveyor
6262
- azure
63+
- awsCodeBuild
6364
- bamboo
6465
- bitbucket
6566
- buildkite
@@ -95,6 +96,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
9596
9697
- appveyor
9798
- azure
99+
- awsCodeBuild
98100
- bamboo
99101
- bitbucket
100102
- buildkite
@@ -131,6 +133,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
131133
132134
- appveyor
133135
- azure
136+
- awsCodeBuild
134137
- bamboo
135138
- bitbucket
136139
- buildkite

packages/server/lib/util/ci_provider.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ const isAzureCi = () => {
3030
return process.env.TF_BUILD && process.env.AZURE_HTTP_USER_AGENT
3131
}
3232

33+
const isAWSCodeBuild = () => {
34+
return _.some(process.env, (val, key) => {
35+
return /^CODEBUILD_/.test(key)
36+
})
37+
}
38+
3339
const isBamboo = () => {
3440
return process.env.bamboo_buildNumber
3541
}
@@ -82,6 +88,7 @@ const isWercker = () => {
8288
const CI_PROVIDERS = {
8389
'appveyor': 'APPVEYOR',
8490
'azure': isAzureCi,
91+
'awsCodeBuild': isAWSCodeBuild,
8592
'bamboo': isBamboo,
8693
'bitbucket': 'BITBUCKET_BUILD_NUMBER',
8794
'buildkite': 'BUILDKITE',
@@ -139,6 +146,13 @@ const _providerCiParams = () => {
139146
'BUILD_CONTAINERID',
140147
'BUILD_REPOSITORY_URI',
141148
]),
149+
awsCodeBuild: extract([
150+
'CODEBUILD_BUILD_ID',
151+
'CODEBUILD_BUILD_NUMBER',
152+
'CODEBUILD_RESOLVED_SOURCE_VERSION',
153+
'CODEBUILD_SOURCE_REPO_URL',
154+
'CODEBUILD_SOURCE_VERSION',
155+
]),
142156
bamboo: extract([
143157
'bamboo_buildNumber',
144158
'bamboo_buildResultsUrl',
@@ -375,6 +389,15 @@ const _providerCommitParams = () => {
375389
// remoteOrigin: ???
376390
// defaultBranch: ???
377391
},
392+
awsCodeBuild: {
393+
sha: env.CODEBUILD_RESOLVED_SOURCE_VERSION,
394+
// branch: ???,
395+
// message: ???
396+
// authorName: ???
397+
// authorEmail: ???
398+
remoteOrigin: env.CODEBUILD_SOURCE_REPO_URL,
399+
// defaultBranch: ???
400+
},
378401
azure: {
379402
sha: env.BUILD_SOURCEVERSION,
380403
branch: env.BUILD_SOURCEBRANCHNAME,

packages/server/test/unit/ci_provider_spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,30 @@ describe('lib/util/ci_provider', () => {
114114
})
115115
})
116116

117+
it('awsCodeBuild', () => {
118+
resetEnv = mockedEnv({
119+
CODEBUILD_BUILD_ID: 'codebuild-demo-project:b1e6661e-e4f2-4156-9ab9-82a19EXAMPLE',
120+
CODEBUILD_BUILD_NUMBER: '123',
121+
CODEBUILD_RESOLVED_SOURCE_VERSION: 'commit',
122+
CODEBUILD_SOURCE_REPO_URL: 'repositoryUrl',
123+
CODEBUILD_SOURCE_VERSION: 'commitOrBranchOrTag',
124+
}, { clear: true })
125+
126+
expectsName('awsCodeBuild')
127+
expectsCiParams({
128+
codebuildBuildId: 'codebuild-demo-project:b1e6661e-e4f2-4156-9ab9-82a19EXAMPLE',
129+
codebuildBuildNumber: '123',
130+
codebuildResolvedSourceVersion: 'commit',
131+
codebuildSourceRepoUrl: 'repositoryUrl',
132+
codebuildSourceVersion: 'commitOrBranchOrTag',
133+
})
134+
135+
return expectsCommitParams({
136+
sha: 'commit',
137+
remoteOrigin: 'repositoryUrl',
138+
})
139+
})
140+
117141
it('bamboo', () => {
118142
resetEnv = mockedEnv({
119143
'bamboo_buildNumber': 'bambooBuildNumber',

0 commit comments

Comments
 (0)