Commit a8e08d0c authored by Georgi N. Georgiev's avatar Georgi N. Georgiev

Merge branch 'skip-cleanup-file' into 'master'

Skip CleanupFileVariables stage if no file variables

Closes #27057

See merge request gitlab-org/gitlab-runner!2456
parents a0387ee9 537c5350
......@@ -735,14 +735,21 @@ func (b *AbstractShell) writeArchiveCacheOnFailureScript(w ShellWriter, info com
}
func (b *AbstractShell) writeCleanupFileVariablesScript(w ShellWriter, info common.ShellScriptInfo) error {
skipCleanupFileVariables := true
for _, variable := range info.Build.GetAllVariables() {
if !variable.File {
continue
}
skipCleanupFileVariables = false
w.RmFile(w.TmpFile(variable.Key))
}
if skipCleanupFileVariables {
return common.ErrSkipBuildStage
}
return nil
}
......
......@@ -970,6 +970,26 @@ func TestSkipBuildStage(t *testing.T) {
},
},
},
common.BuildStageCleanupFileVariables: {
"don't skip if file artifact defined": {
common.JobResponse{
Variables: common.JobVariables{
{
Key: "FILE_VARIABLE",
Value: "CONTENTS",
Public: true,
Internal: true,
File: true,
},
},
},
common.RunnerConfig{
RunnerCredentials: common.RunnerCredentials{
URL: "https://example.com",
},
},
},
},
}
shell := AbstractShell{}
......@@ -996,9 +1016,15 @@ func TestSkipBuildStage(t *testing.T) {
err,
)
// stages with bare minimum requirements should not be skipped
build.JobResponse = tc.JobResponse
build.Runner = &tc.Runner
// stages with bare minimum requirements should not be skipped.
build = &common.Build{
JobResponse: tc.JobResponse,
Runner: &tc.Runner,
}
info = common.ShellScriptInfo{
RunnerCommand: "gitlab-runner-helper",
Build: build,
}
err = shell.writeScript(&BashWriter{}, stage, info)
assert.NoError(t, err, "stage %v should not have been skipped", stage)
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment