From 973a7aead3fe6086177de28a96ded532820534f2 Mon Sep 17 00:00:00 2001 From: gotbadger Date: Fri, 12 Jan 2024 15:29:07 +0000 Subject: [PATCH] feat: add more scan context for gitlab --- internal/flag/repository_flags.go | 4 ++-- internal/flag/repository_flags_test.go | 4 ++-- internal/report/output/saas/saas.go | 1 + internal/report/output/saas/types/types.go | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/flag/repository_flags.go b/internal/flag/repository_flags.go index f065f4308..b1c37f9b9 100644 --- a/internal/flag/repository_flags.go +++ b/internal/flag/repository_flags.go @@ -118,8 +118,8 @@ var ( Value: "", Usage: "Used when fetching branch level ignores for a PR/MR", EnvironmentVariables: []string{ - "PR_NUMBER", // github - "CI_MERGE_REQUEST_ID", //gitlab + "PR_NUMBER", // github + "CI_MERGE_REQUEST_IID", //gitlab }, DisableInConfig: true, Hide: true, diff --git a/internal/flag/repository_flags_test.go b/internal/flag/repository_flags_test.go index 7af935df9..4dbc09549 100644 --- a/internal/flag/repository_flags_test.go +++ b/internal/flag/repository_flags_test.go @@ -306,10 +306,10 @@ func Test_getPullRequestNumberFlag(t *testing.T) { }, }, { - name: "Repository PullRequestNumber. CI_MERGE_REQUEST_ID env", + name: "Repository PullRequestNumber. CI_MERGE_REQUEST_IID env", flag: PullRequestNumberFlag, env: Env{ - key: "CI_MERGE_REQUEST_ID", + key: "CI_MERGE_REQUEST_IID", value: "24", }, want: []string{ diff --git a/internal/report/output/saas/saas.go b/internal/report/output/saas/saas.go index af3fe61e3..f81beb617 100644 --- a/internal/report/output/saas/saas.go +++ b/internal/report/output/saas/saas.go @@ -213,5 +213,6 @@ func getMeta( BearerVersion: build.Version, FoundLanguages: reportData.FoundLanguages, GitlabPipelineId: os.Getenv("CI_PIPELINE_ID"), + GitlabJobId: os.Getenv("CI_JOB_ID"), }, nil } diff --git a/internal/report/output/saas/types/types.go b/internal/report/output/saas/types/types.go index c4d898a56..5923ed497 100644 --- a/internal/report/output/saas/types/types.go +++ b/internal/report/output/saas/types/types.go @@ -23,6 +23,7 @@ type Meta struct { BearerVersion string `json:"bearer_version,omitempty" yaml:"bearer_version,omitempty"` FoundLanguages map[string]int32 `json:"found_languages" yaml:"found_languages"` GitlabPipelineId string `json:"gitlab_pipeline_id,omitempty" yaml:"gitlab_pipeline_id,omitempty"` + GitlabJobId string `json:"gitlab_job_id,omitempty" yaml:"gitlab_job_id,omitempty"` } type BearerReport struct {