diff --git a/api/build/restart.go b/api/build/restart.go index a02d368b4..f8798fbb6 100644 --- a/api/build/restart.go +++ b/api/build/restart.go @@ -117,7 +117,7 @@ func RestartBuild(c *gin.Context) { b.SetSender(cl.Subject) // fetch scm user id - senderID, err := scm.GetUserID(ctx, u.GetName(), u.GetToken()) + senderID, err := scm.GetUserID(ctx, u.GetName(), r.GetOwner().GetToken()) if err != nil { retErr := fmt.Errorf("unable to get SCM user id for %s: %w", u.GetName(), err) diff --git a/cmd/vela-server/schedule.go b/cmd/vela-server/schedule.go index e7e0df759..3709df9a8 100644 --- a/cmd/vela-server/schedule.go +++ b/cmd/vela-server/schedule.go @@ -180,16 +180,10 @@ func processSchedule(ctx context.Context, s *api.Schedule, settings *settings.Pl b.SetRepo(r) b.SetSender(s.GetUpdatedBy()) - // send API call to capture the user for the schedule trigger - u, err := database.GetUserForName(ctx, s.GetUpdatedBy()) - if err != nil { - return fmt.Errorf("unable to get user for name %s: %w", s.GetUpdatedBy(), err) - } - // fetch scm user id - senderID, err := scm.GetUserID(ctx, u.GetName(), u.GetToken()) + senderID, err := scm.GetUserID(ctx, s.GetUpdatedBy(), r.GetOwner().GetToken()) if err != nil { - return fmt.Errorf("unable to get SCM user id for %s: %w", u.GetName(), err) + return fmt.Errorf("unable to get SCM user id for %s: %w", s.GetUpdatedBy(), err) } b.SetSenderSCMID(senderID)