Skip to content
Snippets Groups Projects

fix: read error from upload artifacts execution.

Merged Paul 🐻 requested to merge paulrbr/gitlab-runner:fix-artifact-upload-errors into master
All threads resolved!
2 files
+ 28
19
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 16
19
@@ -173,27 +173,17 @@ func (b *Build) executeStage(ctx context.Context, buildStage BuildStage, executo
}
func (b *Build) executeUploadArtifacts(ctx context.Context, state error, executor Executor) (err error) {
jobState := state
for _, artifacts := range b.Artifacts {
when := artifacts.When
if state == nil {
// Previous stages were successful
if when == "" || when == ArtifactWhenOnSuccess || when == ArtifactWhenAlways {
state = b.executeStage(ctx, BuildStageUploadArtifacts, executor)
}
} else {
// Previous stage did fail
if when == ArtifactWhenOnFailure || when == ArtifactWhenAlways {
err = b.executeStage(ctx, BuildStageUploadArtifacts, executor)
}
var uploadError error
for _, artifact := range b.JobResponse.Artifacts {
if artifact.ShouldUpload(state) {
uploadError = b.executeStage(ctx, BuildStageUploadArtifacts, executor)
}
if uploadError != nil {
err = uploadError
}
}
// Use job's error if set
if jobState != nil {
err = jobState
}
return
}
@@ -226,7 +216,14 @@ func (b *Build) executeScript(ctx context.Context, executor Executor) error {
if err == nil {
err = b.executeStage(ctx, BuildStageArchiveCache, executor)
}
err = b.executeUploadArtifacts(ctx, err, executor)
jobState := err
err = b.executeUploadArtifacts(ctx, jobState, executor)
// Use job's error if set
if jobState != nil {
err = jobState
}
return err
}
Loading