Skip to content

Commit 62d30da

Browse files
chore: collect additional ci envs (#29845)
1 parent 217f27f commit 62d30da

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

packages/server/lib/util/ci_provider.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,20 @@ const _providerCiParams = () => {
154154
'APPVEYOR_PULL_REQUEST_NUMBER',
155155
'APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH',
156156
]),
157+
// https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables
157158
azure: extract([
158159
'BUILD_BUILDID',
159160
'BUILD_BUILDNUMBER',
160161
'BUILD_CONTAINERID',
161162
'BUILD_REPOSITORY_URI',
163+
'SYSTEM_JOBID',
164+
'SYSTEM_STAGEATTEMPT',
165+
'SYSTEM_PHASEATTEMPT',
166+
'SYSTEM_JOBATTEMPT',
167+
'SYSTEM_PLANID',
162168
'SYSTEM_PULLREQUEST_PULLREQUESTNUMBER',
169+
'SYSTEM_PULLREQUEST_TARGETBRANCH',
170+
'SYSTEM_PULLREQUEST_TARGETBRANCHNAME',
163171
]),
164172
awsCodeBuild: extract([
165173
'CODEBUILD_BUILD_ID',
@@ -206,6 +214,8 @@ const _providerCiParams = () => {
206214
'CIRCLE_PR_USERNAME',
207215
'CIRCLE_COMPARE_URL',
208216
'CIRCLE_WORKFLOW_ID',
217+
'CIRCLE_WORKFLOW_JOB_ID',
218+
'CIRCLE_PIPELINE_ID',
209219
'CIRCLE_PULL_REQUEST',
210220
'CIRCLE_REPOSITORY_URL',
211221
'CI_PULL_REQUEST',
@@ -224,6 +234,8 @@ const _providerCiParams = () => {
224234
'CI_BUILD_ID',
225235
'CI_REPO_NAME',
226236
'CI_PROJECT_ID',
237+
'CI_PR_NUMBER',
238+
'CI_PULL_REQUEST',
227239
]),
228240
// https://concourse-ci.org/implementing-resource-types.html#resource-metadata
229241
concourse: extract([
@@ -266,6 +278,7 @@ const _providerCiParams = () => {
266278
'GITHUB_HEAD_REF',
267279
'GITHUB_REF_NAME',
268280
'GITHUB_REF',
281+
'GITHUB_JOB',
269282
]),
270283
// see https://docs.gitlab.com/ee/ci/variables/
271284
gitlab: extract([
@@ -284,7 +297,9 @@ const _providerCiParams = () => {
284297
'CI_REPOSITORY_URL',
285298
'CI_ENVIRONMENT_URL',
286299
'CI_DEFAULT_BRANCH',
287-
// for PRs: https://gitlab.com/gitlab-org/gitlab-ce/issues/23902
300+
// for PRs: https://gitlab.com/gitlab-org/gitlab-ce/issues/23902
301+
'CI_MERGE_REQUEST_SOURCE_BRANCH_NAME',
302+
'CI_MERGE_REQUEST_SOURCE_BRANCH_SHA',
288303
]),
289304
// https://docs.gocd.org/current/faq/dev_use_current_revision_in_build.html#standard-gocd-environment-variables
290305
goCD: extract([
@@ -312,6 +327,9 @@ const _providerCiParams = () => {
312327
'TAG_NAME',
313328
'COMMIT_SHA',
314329
'SHORT_SHA',
330+
'_HEAD_BRANCH',
331+
'_BASE_BRANCH',
332+
'_PR_NUMBER',
315333
// https://cloud.google.com/cloud-build/docs/api/reference/rest/Shared.Types/Build
316334
]),
317335
/**

packages/server/test/unit/util/ci_provider_spec.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,16 @@ describe('lib/util/ci_provider', () => {
353353
it('circle', () => {
354354
resetEnv = mockedEnv({
355355
CIRCLECI: 'true',
356-
357356
CIRCLE_JOB: 'circleJob',
358357
CIRCLE_BUILD_NUM: 'circleBuildNum',
359358
CIRCLE_BUILD_URL: 'circleBuildUrl',
360359
CIRCLE_PR_NUMBER: 'circlePrNumber',
361360
CIRCLE_PR_REPONAME: 'circlePrReponame',
362361
CIRCLE_PR_USERNAME: 'circlePrUsername',
363362
CIRCLE_COMPARE_URL: 'circleCompareUrl',
363+
CIRCLE_PIPELINE_ID: 'circlePipelineId',
364364
CIRCLE_WORKFLOW_ID: 'circleWorkflowId',
365+
CIRCLE_WORKFLOW_JOB_ID: 'circleWorkflowJobId',
365366
CIRCLE_PULL_REQUEST: 'circlePullRequest',
366367
CIRCLE_REPOSITORY_URL: 'circleRepositoryUrl',
367368
CI_PULL_REQUEST: 'ciPullRequest',
@@ -380,7 +381,9 @@ describe('lib/util/ci_provider', () => {
380381
circlePrReponame: 'circlePrReponame',
381382
circlePrUsername: 'circlePrUsername',
382383
circleCompareUrl: 'circleCompareUrl',
384+
circlePipelineId: 'circlePipelineId',
383385
circleWorkflowId: 'circleWorkflowId',
386+
circleWorkflowJobId: 'circleWorkflowJobId',
384387
circlePullRequest: 'circlePullRequest',
385388
circleRepositoryUrl: 'circleRepositoryUrl',
386389
ciPullRequest: 'ciPullRequest',
@@ -444,13 +447,17 @@ describe('lib/util/ci_provider', () => {
444447
CI_COMMIT_MESSAGE: 'ciCommitMessage',
445448
CI_COMMITTER_NAME: 'ciCommitterName',
446449
CI_COMMITTER_EMAIL: 'ciCommitterEmail',
450+
CI_PR_NUMBER: 'prNumber',
451+
CI_PULL_REQUEST: 'pullRequest',
447452
}, { clear: true })
448453

449454
expectsName('codeshipPro')
450455
expectsCiParams({
451456
ciBuildId: 'ciBuildId',
452457
ciRepoName: 'ciRepoName',
453458
ciProjectId: 'ciProjectId',
459+
ciPrNumber: 'prNumber',
460+
ciPullRequest: 'pullRequest',
454461
})
455462

456463
return expectsCommitParams({
@@ -568,6 +575,7 @@ describe('lib/util/ci_provider', () => {
568575
GITHUB_ACTION: 'ciGitHubActionId',
569576
GITHUB_EVENT_NAME: 'ciEventName',
570577
GITHUB_RUN_ID: 'ciGithubRunId',
578+
GITHUB_JOB: 'jobName',
571579
GITHUB_RUN_ATTEMPT: 'ciGithubRunAttempt',
572580
GITHUB_REPOSITORY: 'ciGithubRepository',
573581
GITHUB_SHA: 'ciCommitSha',
@@ -586,6 +594,7 @@ describe('lib/util/ci_provider', () => {
586594
githubRepository: 'ciGithubRepository',
587595
githubRunAttempt: 'ciGithubRunAttempt',
588596
githubRunId: 'ciGithubRunId',
597+
githubJob: 'jobName',
589598
githubBaseRef: 'ciBaseRef',
590599
githubHeadRef: 'ciHeadRef',
591600
githubRefName: 'ciRefName',
@@ -653,6 +662,8 @@ describe('lib/util/ci_provider', () => {
653662
CI_COMMIT_MESSAGE: 'ciCommitMessage',
654663
GITLAB_USER_NAME: 'gitlabUserName',
655664
GITLAB_USER_EMAIL: 'gitlabUserEmail',
665+
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME: 'sourceBranchName',
666+
CI_MERGE_REQUEST_SOURCE_BRANCH_SHA: 'sourceBranchSha',
656667
}, { clear: true })
657668

658669
expectsName('gitlab')
@@ -669,6 +680,8 @@ describe('lib/util/ci_provider', () => {
669680
ciRepositoryUrl: 'ciRepositoryUrl',
670681
ciEnvironmentUrl: 'ciEnvironmentUrl',
671682
ciDefaultBranch: 'ciDefaultBranch',
683+
ciMergeRequestSourceBranchName: 'sourceBranchName',
684+
ciMergeRequestSourceBranchSha: 'sourceBranchSha',
672685
})
673686

674687
expectsCommitParams({
@@ -741,6 +754,9 @@ describe('lib/util/ci_provider', () => {
741754

742755
COMMIT_SHA: 'commitSha',
743756
BRANCH_NAME: 'branchName',
757+
_HEAD_BRANCH: 'headBranch',
758+
_BASE_BRANCH: 'baseBranch',
759+
_PR_NUMBER: 'prNumber',
744760
}, { clear: true })
745761

746762
expectsName('googleCloud')
@@ -749,6 +765,9 @@ describe('lib/util/ci_provider', () => {
749765
projectId: 'projectId',
750766
commitSha: 'commitSha',
751767
branchName: 'branchName',
768+
headBranch: 'headBranch',
769+
baseBranch: 'baseBranch',
770+
prNumber: 'prNumber',
752771
})
753772

754773
expectsCommitParams({
@@ -1137,7 +1156,14 @@ describe('lib/util/ci_provider', () => {
11371156
BUILD_BUILDNUMBER: 'buildNumber',
11381157
BUILD_CONTAINERID: 'containerId',
11391158
BUILD_REPOSITORY_URI: 'buildRepositoryUri',
1159+
SYSTEM_PLANID: 'planId',
11401160
SYSTEM_PULLREQUEST_PULLREQUESTNUMBER: 'systemPullrequestPullrequestnumber',
1161+
SYSTEM_PULLREQUEST_TARGETBRANCH: 'targetBranch',
1162+
SYSTEM_PULLREQUEST_TARGETBRANCHNAME: 'targetBranchName',
1163+
SYSTEM_JOBID: 'jobid',
1164+
SYSTEM_STAGEATTEMPT: 'stageAttempt',
1165+
SYSTEM_PHASEATTEMPT: 'phaseAttempt',
1166+
SYSTEM_JOBATTEMPT: 'jobAttempt',
11411167

11421168
BUILD_SOURCEVERSION: 'commit',
11431169
BUILD_SOURCEBRANCHNAME: 'branch',
@@ -1152,7 +1178,14 @@ describe('lib/util/ci_provider', () => {
11521178
buildBuildnumber: 'buildNumber',
11531179
buildContainerid: 'containerId',
11541180
buildRepositoryUri: 'buildRepositoryUri',
1181+
systemPlanid: 'planId',
11551182
systemPullrequestPullrequestnumber: 'systemPullrequestPullrequestnumber',
1183+
systemPullrequestTargetbranch: 'targetBranch',
1184+
systemPullrequestTargetbranchname: 'targetBranchName',
1185+
systemJobid: 'jobid',
1186+
systemStageattempt: 'stageAttempt',
1187+
systemPhaseattempt: 'phaseAttempt',
1188+
systemJobattempt: 'jobAttempt',
11561189
})
11571190

11581191
return expectsCommitParams({

0 commit comments

Comments
 (0)