Skip to content

Commit f6233af

Browse files
authored
feat: send CI variables for CloudFresh (#15117)
1 parent 181f8ac commit f6233af

3 files changed

Lines changed: 70 additions & 0 deletions

File tree

packages/server/__snapshots__/cypress_spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
6868
- codeshipBasic
6969
- codeshipPro
7070
- concourse
71+
- codeFresh
7172
- drone
7273
- githubActions
7374
- gitlab
@@ -104,6 +105,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
104105
- codeshipBasic
105106
- codeshipPro
106107
- concourse
108+
- codeFresh
107109
- drone
108110
- githubActions
109111
- gitlab
@@ -141,6 +143,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
141143
- codeshipBasic
142144
- codeshipPro
143145
- concourse
146+
- codeFresh
144147
- drone
145148
- githubActions
146149
- gitlab

packages/server/lib/util/ci_provider.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ const CI_PROVIDERS = {
9696
'codeshipBasic': isCodeshipBasic,
9797
'codeshipPro': isCodeshipPro,
9898
'concourse': isConcourse,
99+
codeFresh: 'CF_BUILD_ID',
99100
'drone': 'DRONE',
100101
githubActions: 'GITHUB_ACTIONS',
101102
'gitlab': isGitlab,
@@ -218,6 +219,20 @@ const _providerCiParams = () => {
218219
'BUILD_TEAM_NAME',
219220
'ATC_EXTERNAL_URL',
220221
]),
222+
// https://codefresh.io/docs/docs/codefresh-yaml/variables/
223+
codeFresh: extract([
224+
'CF_BUILD_ID',
225+
'CF_BUILD_URL',
226+
'CF_CURRENT_ATTEMPT',
227+
'CF_STEP_NAME',
228+
'CF_PIPELINE_NAME',
229+
'CF_PIPELINE_TRIGGER_ID',
230+
// variables added for pull requests
231+
'CF_PULL_REQUEST_ID',
232+
'CF_PULL_REQUEST_IS_FORK',
233+
'CF_PULL_REQUEST_NUMBER',
234+
'CF_PULL_REQUEST_TARGET',
235+
]),
221236
drone: extract([
222237
'DRONE_JOB_NUMBER',
223238
'DRONE_BUILD_LINK',
@@ -465,6 +480,12 @@ const _providerCommitParams = () => {
465480
// remoteOrigin: ???
466481
// defaultBranch: ???
467482
},
483+
codeFresh: {
484+
sha: env.CF_REVISION,
485+
branch: env.CF_BRANCH,
486+
message: env.CF_COMMIT_MESSAGE,
487+
authorName: env.CF_COMMIT_AUTHOR,
488+
},
468489
drone: {
469490
sha: env.DRONE_COMMIT_SHA,
470491
branch: env.DRONE_COMMIT_BRANCH,

packages/server/test/unit/ci_provider_spec.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,52 @@ describe('lib/util/ci_provider', () => {
458458
return expectsCommitParams(null)
459459
})
460460

461+
it('codeFresh', () => {
462+
resetEnv = mockedEnv({
463+
// build information
464+
'CF_BUILD_ID': 'cfBuildId',
465+
'CF_BUILD_URL': 'cfBuildUrl',
466+
'CF_CURRENT_ATTEMPT': 'cfCurrentAttempt',
467+
'CF_STEP_NAME': 'cfStepName',
468+
'CF_PIPELINE_NAME': 'cfPipelineName',
469+
'CF_PIPELINE_TRIGGER_ID': 'cfPipelineTriggerId',
470+
471+
// variables added for pull requests
472+
'CF_PULL_REQUEST_ID': 'cfPullRequestId',
473+
'CF_PULL_REQUEST_IS_FORK': 'cfPullRequestIsFork',
474+
'CF_PULL_REQUEST_NUMBER': 'cfPullRequestNumber',
475+
'CF_PULL_REQUEST_TARGET': 'cfPullRequestTarget',
476+
477+
// git information
478+
CF_REVISION: 'cfRevision',
479+
CF_BRANCH: 'cfBranch',
480+
CF_COMMIT_MESSAGE: 'cfCommitMessage',
481+
CF_COMMIT_AUTHOR: 'cfCommitAuthor',
482+
}, { clear: true })
483+
484+
expectsName('codeFresh')
485+
expectsCiParams({
486+
cfBuildId: 'cfBuildId',
487+
cfBuildUrl: 'cfBuildUrl',
488+
cfCurrentAttempt: 'cfCurrentAttempt',
489+
cfStepName: 'cfStepName',
490+
cfPipelineName: 'cfPipelineName',
491+
cfPipelineTriggerId: 'cfPipelineTriggerId',
492+
// pull request variables
493+
cfPullRequestId: 'cfPullRequestId',
494+
cfPullRequestIsFork: 'cfPullRequestIsFork',
495+
cfPullRequestNumber: 'cfPullRequestNumber',
496+
cfPullRequestTarget: 'cfPullRequestTarget',
497+
})
498+
499+
expectsCommitParams({
500+
sha: 'cfRevision',
501+
branch: 'cfBranch',
502+
message: 'cfCommitMessage',
503+
authorName: 'cfCommitAuthor',
504+
})
505+
})
506+
461507
it('drone', () => {
462508
resetEnv = mockedEnv({
463509
DRONE: 'true',

0 commit comments

Comments
 (0)