MCPcopy Create free account
hub / github.com/cli/cli / GetJobs

Function GetJobs

pkg/cmd/run/shared/shared.go:490–523  ·  view source on GitHub ↗
(client *api.Client, repo ghrepo.Interface, runID int64, jobsURL safeurl.SafeURL, attempt uint64)

Source from the content-addressed store, hash-verified

488}
489
490func GetJobs(client *api.Client, repo ghrepo.Interface, runID int64, jobsURL safeurl.SafeURL, attempt uint64) ([]Job, error) {
491 var jobsPath safeurl.SafeURL
492 if attempt > 0 {
493 p, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "runs", strconv.FormatInt(runID, 10), "attempts", strconv.FormatUint(attempt, 10), "jobs")
494 if err != nil {
495 return nil, err
496 }
497 p.SetQuery("per_page", "100")
498 jobsPath = p
499 } else {
500 u, err := url.Parse(jobsURL.String())
501 if err != nil {
502 return nil, err
503 }
504 query := url.Values{}
505 query.Set("per_page", "100")
506 u.RawQuery = query.Encode()
507 // Since u is derived from jobsURL, an already-trusted safeurl.SafeURL, the resulting URL is safe to declare as such.
508 jobsPath = safeurl.NewImmutableSafeURL(u.String())
509 }
510
511 // A non-nil empty slice is returned so callers can tell that jobs were fetched and there are none (if len is zero).
512 jobs := []Job{}
513 for jobsPath.String() != "" {
514 var resp JobsPayload
515 next, err := client.RESTWithNext(repo.RepoHost(), http.MethodGet, jobsPath.String(), nil, &resp)
516 if err != nil {
517 return nil, err
518 }
519 jobs = append(jobs, resp.Jobs...)
520 jobsPath = safeurl.NewImmutableSafeURL(next)
521 }
522 return jobs, nil
523}
524
525func GetJob(client *api.Client, repo ghrepo.Interface, jobID string) (*Job, error) {
526 path, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "actions", "jobs", jobID)

Callers 2

runViewFunction · 0.92
renderRunFunction · 0.92

Calls 9

StringMethod · 0.95
JoinPathFunction · 0.92
NewImmutableSafeURLFunction · 0.92
SetQueryMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
SetMethod · 0.65
RESTWithNextMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected