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!
Files
435
+ 16
35
@@ -9,7 +9,6 @@ import (
@@ -9,7 +9,6 @@ import (
"path"
"path"
"strconv"
"strconv"
"strings"
"strings"
"sync"
"time"
"time"
"github.com/Sirupsen/logrus"
"github.com/Sirupsen/logrus"
@@ -174,42 +173,17 @@ func (b *Build) executeStage(ctx context.Context, buildStage BuildStage, executo
@@ -174,42 +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) {
func (b *Build) executeUploadArtifacts(ctx context.Context, state error, executor Executor) (err error) {
jobState := state
var uploadError error
var wait sync.WaitGroup
var uploadErrors []error
for _, artifact := range b.JobResponse.Artifacts {
if artifact.ShouldUpload(state) {
// Execute upload stages in parallel
uploadError = b.executeStage(ctx, BuildStageUploadArtifacts, executor)
for _, artifact := range b.Artifacts {
}
when := artifact.When
if uploadError != nil {
if state == nil {
err = uploadError
// Previous stages were successful
if when == "" || when == ArtifactWhenOnSuccess || when == ArtifactWhenAlways {
wait.Add(1)
go func() {
uploadErrors = append(uploadErrors, b.executeStage(ctx, BuildStageUploadArtifacts, executor))
wait.Done()
}()
}
} else {
// Previous stage did fail
if when == ArtifactWhenOnFailure || when == ArtifactWhenAlways {
wait.Add(1)
go func() {
uploadErrors = append(uploadErrors, b.executeStage(ctx, BuildStageUploadArtifacts, executor))
wait.Done()
}()
}
}
}
}
}
wait.Wait()
// Use job's error if set
if jobState != nil {
err = jobState
}
if err == nil {
err = uploadErrors[0]
}
return
return
}
}
@@ -242,7 +216,14 @@ func (b *Build) executeScript(ctx context.Context, executor Executor) error {
@@ -242,7 +216,14 @@ func (b *Build) executeScript(ctx context.Context, executor Executor) error {
if err == nil {
if err == nil {
err = b.executeStage(ctx, BuildStageArchiveCache, executor)
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
return err
}
}
Loading