mirror of
https://gitea.com/gitea/act_runner.git
synced 2024-12-27 19:38:20 +01:00
fix: report job failure on error return (#14)
act_runner only returns the error to the runner, but doesn't update the job result to failure. Co-authored-by: Christopher Homberger <christopher.homberger@web.de> Reviewed-on: https://gitea.com/gitea/act_runner/pulls/14 Reviewed-by: Jason Song <i@wolfogre.com> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: ChristopherHX <christopherhx@noreply.gitea.io> Co-committed-by: ChristopherHX <christopherhx@noreply.gitea.io>
This commit is contained in:
parent
cf27d3f300
commit
f7a52789d9
@ -112,7 +112,7 @@ func getToken(task *runnerv1.Task) string {
|
|||||||
return token
|
return token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
|
func (t *Task) Run(ctx context.Context, task *runnerv1.Task) (lastErr error) {
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
_, exist := globalTaskMap.Load(task.Id)
|
_, exist := globalTaskMap.Load(task.Id)
|
||||||
@ -128,6 +128,14 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
|
|||||||
lastWords := ""
|
lastWords := ""
|
||||||
reporter := NewReporter(ctx, cancel, t.client, task)
|
reporter := NewReporter(ctx, cancel, t.client, task)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
// set the job to failed on an error return value
|
||||||
|
if lastErr != nil {
|
||||||
|
reporter.Fire(&log.Entry{
|
||||||
|
Data: log.Fields{
|
||||||
|
"jobResult": "failure",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
_ = reporter.Close(lastWords)
|
_ = reporter.Close(lastWords)
|
||||||
}()
|
}()
|
||||||
reporter.RunDaemon()
|
reporter.RunDaemon()
|
||||||
|
Loading…
Reference in New Issue
Block a user