diff --git a/packages/server/__snapshots__/cypress_spec.js b/packages/server/__snapshots__/cypress_spec.js index c63d647a9a50..5e0b18126f41 100644 --- a/packages/server/__snapshots__/cypress_spec.js +++ b/packages/server/__snapshots__/cypress_spec.js @@ -60,6 +60,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the - appveyor - azure +- awsCodeBuild - bamboo - bitbucket - buildkite @@ -95,6 +96,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the - appveyor - azure +- awsCodeBuild - bamboo - bitbucket - buildkite @@ -131,6 +133,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the - appveyor - azure +- awsCodeBuild - bamboo - bitbucket - buildkite diff --git a/packages/server/lib/util/ci_provider.js b/packages/server/lib/util/ci_provider.js index dfdf244b098b..0b84a6042e4e 100644 --- a/packages/server/lib/util/ci_provider.js +++ b/packages/server/lib/util/ci_provider.js @@ -30,6 +30,12 @@ const isAzureCi = () => { return process.env.TF_BUILD && process.env.AZURE_HTTP_USER_AGENT } +const isAWSCodeBuild = () => { + return _.some(process.env, (val, key) => { + return /^CODEBUILD_/.test(key) + }) +} + const isBamboo = () => { return process.env.bamboo_buildNumber } @@ -82,6 +88,7 @@ const isWercker = () => { const CI_PROVIDERS = { 'appveyor': 'APPVEYOR', 'azure': isAzureCi, + 'awsCodeBuild': isAWSCodeBuild, 'bamboo': isBamboo, 'bitbucket': 'BITBUCKET_BUILD_NUMBER', 'buildkite': 'BUILDKITE', @@ -139,6 +146,13 @@ const _providerCiParams = () => { 'BUILD_CONTAINERID', 'BUILD_REPOSITORY_URI', ]), + awsCodeBuild: extract([ + 'CODEBUILD_BUILD_ID', + 'CODEBUILD_BUILD_NUMBER', + 'CODEBUILD_RESOLVED_SOURCE_VERSION', + 'CODEBUILD_SOURCE_REPO_URL', + 'CODEBUILD_SOURCE_VERSION', + ]), bamboo: extract([ 'bamboo_buildNumber', 'bamboo_buildResultsUrl', @@ -375,6 +389,15 @@ const _providerCommitParams = () => { // remoteOrigin: ??? // defaultBranch: ??? }, + awsCodeBuild: { + sha: env.CODEBUILD_RESOLVED_SOURCE_VERSION, + // branch: ???, + // message: ??? + // authorName: ??? + // authorEmail: ??? + remoteOrigin: env.CODEBUILD_SOURCE_REPO_URL, + // defaultBranch: ??? + }, azure: { sha: env.BUILD_SOURCEVERSION, branch: env.BUILD_SOURCEBRANCHNAME, diff --git a/packages/server/test/unit/ci_provider_spec.js b/packages/server/test/unit/ci_provider_spec.js index 05d47fa232f4..6f98a91f3355 100644 --- a/packages/server/test/unit/ci_provider_spec.js +++ b/packages/server/test/unit/ci_provider_spec.js @@ -114,6 +114,30 @@ describe('lib/util/ci_provider', () => { }) }) + it('awsCodeBuild', () => { + resetEnv = mockedEnv({ + CODEBUILD_BUILD_ID: 'codebuild-demo-project:b1e6661e-e4f2-4156-9ab9-82a19EXAMPLE', + CODEBUILD_BUILD_NUMBER: '123', + CODEBUILD_RESOLVED_SOURCE_VERSION: 'commit', + CODEBUILD_SOURCE_REPO_URL: 'repositoryUrl', + CODEBUILD_SOURCE_VERSION: 'commitOrBranchOrTag', + }, { clear: true }) + + expectsName('awsCodeBuild') + expectsCiParams({ + codebuildBuildId: 'codebuild-demo-project:b1e6661e-e4f2-4156-9ab9-82a19EXAMPLE', + codebuildBuildNumber: '123', + codebuildResolvedSourceVersion: 'commit', + codebuildSourceRepoUrl: 'repositoryUrl', + codebuildSourceVersion: 'commitOrBranchOrTag', + }) + + return expectsCommitParams({ + sha: 'commit', + remoteOrigin: 'repositoryUrl', + }) + }) + it('bamboo', () => { resetEnv = mockedEnv({ 'bamboo_buildNumber': 'bambooBuildNumber',