Add runner name to log (#37)

User can get the name of the runner that executed the specified job.
![image](/attachments/61328f68-7223-4345-85c7-ac08781e81db)

Co-authored-by: Zettat123 <zettat123@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/37
Reviewed-by: Jason Song <i@wolfogre.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Zettat123 <zettat123@noreply.gitea.io>
Co-committed-by: Zettat123 <zettat123@noreply.gitea.io>
This commit is contained in:
Zettat123
2023-03-06 18:42:07 +08:00
committed by Lunny Xiao
parent e36300ce28
commit f24e0721dc
4 changed files with 11 additions and 4 deletions

View File

@ -115,7 +115,7 @@ func getToken(task *runnerv1.Task) string {
return token
}
func (t *Task) Run(ctx context.Context, task *runnerv1.Task) (lastErr error) {
func (t *Task) Run(ctx context.Context, task *runnerv1.Task, runnerName string) (lastErr error) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
_, exist := globalTaskMap.Load(task.Id)
@ -143,7 +143,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task) (lastErr error) {
}()
reporter.RunDaemon()
reporter.Logf("received task %v of job %v", task.Id, task.Context.Fields["job"].GetStringValue())
reporter.Logf("%s received task %v of job %v", runnerName, task.Id, task.Context.Fields["job"].GetStringValue())
workflowsPath, err := getWorkflowsPath(t.Input.repoDirectory)
if err != nil {