MCPcopy
hub / github.com/cli/cli / GetJobs

Function GetJobs

pkg/cmd/run/shared/shared.go:478–503  ·  view source on GitHub ↗
(client *api.Client, repo ghrepo.Interface, run *Run, attempt uint64)

Source from the content-addressed store, hash-verified

476}
477
478func GetJobs(client *api.Client, repo ghrepo.Interface, run *Run, attempt uint64) ([]Job, error) {
479 if run.Jobs != nil {
480 return run.Jobs, nil
481 }
482
483 query := url.Values{}
484 query.Set("per_page", "100")
485 jobsPath := fmt.Sprintf("%s?%s", run.JobsURL, query.Encode())
486
487 if attempt > 0 {
488 jobsPath = fmt.Sprintf("repos/%s/actions/runs/%d/attempts/%d/jobs?%s", ghrepo.FullName(repo), run.ID, attempt, query.Encode())
489 }
490
491 for jobsPath != "" {
492 var resp JobsPayload
493 var err error
494 jobsPath, err = client.RESTWithNext(repo.RepoHost(), http.MethodGet, jobsPath, nil, &resp)
495 if err != nil {
496 run.Jobs = nil
497 return nil, err
498 }
499
500 run.Jobs = append(run.Jobs, resp.Jobs...)
501 }
502 return run.Jobs, nil
503}
504
505func GetJob(client *api.Client, repo ghrepo.Interface, jobID string) (*Job, error) {
506 path := fmt.Sprintf("repos/%s/actions/jobs/%s", ghrepo.FullName(repo), jobID)

Callers 2

runViewFunction · 0.92
renderRunFunction · 0.92

Calls 4

FullNameFunction · 0.92
SetMethod · 0.65
RESTWithNextMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected