Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: send CI variables for CloudFresh #15117

Merged
merged 6 commits into from Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/server/__snapshots__/cypress_spec.js
Expand Up @@ -68,6 +68,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
- codeshipBasic
- codeshipPro
- concourse
- codeFresh
- drone
- githubActions
- gitlab
Expand Down Expand Up @@ -104,6 +105,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
- codeshipBasic
- codeshipPro
- concourse
- codeFresh
- drone
- githubActions
- gitlab
Expand Down Expand Up @@ -141,6 +143,7 @@ The ciBuildId is automatically detected if you are running Cypress in any of the
- codeshipBasic
- codeshipPro
- concourse
- codeFresh
- drone
- githubActions
- gitlab
Expand Down
21 changes: 21 additions & 0 deletions packages/server/lib/util/ci_provider.js
Expand Up @@ -96,6 +96,7 @@ const CI_PROVIDERS = {
'codeshipBasic': isCodeshipBasic,
'codeshipPro': isCodeshipPro,
'concourse': isConcourse,
codeFresh: 'CF_BUILD_ID',
'drone': 'DRONE',
githubActions: 'GITHUB_ACTIONS',
'gitlab': isGitlab,
Expand Down Expand Up @@ -218,6 +219,20 @@ const _providerCiParams = () => {
'BUILD_TEAM_NAME',
'ATC_EXTERNAL_URL',
]),
// https://codefresh.io/docs/docs/codefresh-yaml/variables/
codeFresh: extract([
'CF_BUILD_ID',
'CF_BUILD_URL',
'CF_CURRENT_ATTEMPT',
'CF_STEP_NAME',
'CF_PIPELINE_NAME',
'CF_PIPELINE_TRIGGER_ID',
// variables added for pull requests
'CF_PULL_REQUEST_ID',
'CF_PULL_REQUEST_IS_FORK',
'CF_PULL_REQUEST_NUMBER',
'CF_PULL_REQUEST_TARGET',
]),
drone: extract([
'DRONE_JOB_NUMBER',
'DRONE_BUILD_LINK',
Expand Down Expand Up @@ -465,6 +480,12 @@ const _providerCommitParams = () => {
// remoteOrigin: ???
// defaultBranch: ???
},
codeFresh: {
sha: env.CF_REVISION,
branch: env.CF_BRANCH,
message: env.CF_COMMIT_MESSAGE,
authorName: env.CF_COMMIT_AUTHOR,
},
drone: {
sha: env.DRONE_COMMIT_SHA,
branch: env.DRONE_COMMIT_BRANCH,
Expand Down
46 changes: 46 additions & 0 deletions packages/server/test/unit/ci_provider_spec.js
Expand Up @@ -458,6 +458,52 @@ describe('lib/util/ci_provider', () => {
return expectsCommitParams(null)
})

it('codeFresh', () => {
resetEnv = mockedEnv({
// build information
'CF_BUILD_ID': 'cfBuildId',
'CF_BUILD_URL': 'cfBuildUrl',
'CF_CURRENT_ATTEMPT': 'cfCurrentAttempt',
'CF_STEP_NAME': 'cfStepName',
'CF_PIPELINE_NAME': 'cfPipelineName',
'CF_PIPELINE_TRIGGER_ID': 'cfPipelineTriggerId',

// variables added for pull requests
'CF_PULL_REQUEST_ID': 'cfPullRequestId',
'CF_PULL_REQUEST_IS_FORK': 'cfPullRequestIsFork',
'CF_PULL_REQUEST_NUMBER': 'cfPullRequestNumber',
'CF_PULL_REQUEST_TARGET': 'cfPullRequestTarget',

// git information
CF_REVISION: 'cfRevision',
CF_BRANCH: 'cfBranch',
CF_COMMIT_MESSAGE: 'cfCommitMessage',
CF_COMMIT_AUTHOR: 'cfCommitAuthor',
}, { clear: true })

expectsName('codeFresh')
expectsCiParams({
cfBuildId: 'cfBuildId',
cfBuildUrl: 'cfBuildUrl',
cfCurrentAttempt: 'cfCurrentAttempt',
cfStepName: 'cfStepName',
cfPipelineName: 'cfPipelineName',
cfPipelineTriggerId: 'cfPipelineTriggerId',
// pull request variables
cfPullRequestId: 'cfPullRequestId',
cfPullRequestIsFork: 'cfPullRequestIsFork',
cfPullRequestNumber: 'cfPullRequestNumber',
cfPullRequestTarget: 'cfPullRequestTarget',
})

expectsCommitParams({
sha: 'cfRevision',
branch: 'cfBranch',
message: 'cfCommitMessage',
authorName: 'cfCommitAuthor',
})
})

it('drone', () => {
resetEnv = mockedEnv({
DRONE: 'true',
Expand Down