mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2024-11-28 01:14:25 +03: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
1 changed files with 9 additions and 1 deletions
|
@ -112,7 +112,7 @@ func getToken(task *runnerv1.Task) string {
|
|||
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)
|
||||
defer cancel()
|
||||
_, exist := globalTaskMap.Load(task.Id)
|
||||
|
@ -128,6 +128,14 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) error {
|
|||
lastWords := ""
|
||||
reporter := NewReporter(ctx, cancel, t.client, task)
|
||||
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.RunDaemon()
|
||||
|
|
Loading…
Reference in a new issue