mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-14 20:03:42 +00: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 <[email protected]> Reviewed-on: https://gitea.com/gitea/act_runner/pulls/14 Reviewed-by: Jason Song <[email protected]> Reviewed-by: Lunny Xiao <[email protected]> Co-authored-by: ChristopherHX <[email protected]> Co-committed-by: ChristopherHX <[email protected]>
This commit is contained in:
1 parent
cf27d3f300
commit
f7a52789d9
1 file changed
+9
-1
+9
-1
@@ -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()
|
||||||
|
|||||||
Reference in new issue
Block a user