Skip to content

Commit 7528ac2

Browse files
authored
fix(gitlab-runner): make description env optional (#2490)
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
1 parent b3dc82d commit 7528ac2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

pkg/attestation/crafter/runners/gitlabpipeline.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (r *GitlabPipeline) ListEnvVars() []*EnvVarDefinition {
6868
{"CI_JOB_URL", false},
6969
{"CI_PIPELINE_URL", false},
7070
{"CI_RUNNER_VERSION", false},
71-
{"CI_RUNNER_DESCRIPTION", false},
71+
{"CI_RUNNER_DESCRIPTION", true},
7272
{"CI_COMMIT_REF_NAME", false},
7373
}
7474
}

pkg/attestation/crafter/runners/gitlabpipeline_test.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (s *gitlabPipelineSuite) TestListEnvVars() {
8989
{"CI_JOB_URL", false},
9090
{"CI_PIPELINE_URL", false},
9191
{"CI_RUNNER_VERSION", false},
92-
{"CI_RUNNER_DESCRIPTION", false},
92+
{"CI_RUNNER_DESCRIPTION", true},
9393
{"CI_COMMIT_REF_NAME", false},
9494
}, s.runner.ListEnvVars())
9595
}
@@ -111,6 +111,26 @@ func (s *gitlabPipelineSuite) TestResolveEnvVars() {
111111
}, resolvedEnvVars)
112112
}
113113

114+
func (s *gitlabPipelineSuite) TestResolveEnvVarsWithoutRunnerDescription() {
115+
s.T().Setenv("CI_RUNNER_DESCRIPTION", "")
116+
117+
resolvedEnvVars, errors := s.runner.ResolveEnvVars()
118+
s.Empty(errors, "Should not error when CI_RUNNER_DESCRIPTION is missing")
119+
120+
expected := map[string]string{
121+
"GITLAB_USER_EMAIL": "foo@foo.com",
122+
"GITLAB_USER_LOGIN": "foo",
123+
"CI_PROJECT_URL": "https://gitlab.com/chainloop/chainloop",
124+
"CI_COMMIT_SHA": "1234567890",
125+
"CI_JOB_URL": "https://gitlab.com/chainloop/chainloop/-/jobs/123",
126+
"CI_PIPELINE_URL": "https://gitlab.com/chainloop/chainloop/-/pipelines/123",
127+
"CI_RUNNER_VERSION": "13.10.0",
128+
"CI_COMMIT_REF_NAME": "main",
129+
"CI_SERVER_URL": "https://gitlab.com",
130+
}
131+
s.Equal(expected, resolvedEnvVars)
132+
}
133+
114134
func (s *gitlabPipelineSuite) TestRunURI() {
115135
s.Equal("https://gitlab.com/chainloop/chainloop/-/jobs/123", s.runner.RunURI())
116136
}

0 commit comments

Comments
 (0)