Double_Mind
Double_Mind

Reputation: 89

GitLab API: filter jobs from pipeline by its name

I have a URL on GitLab API which has the next structure: gitlab.com/api/v4/projects/:proj_id/pipelines/:pipeline_id/jobs

Now I want to get only one job with the next name: "rpm:build".

Request like gitlab.com/.../jobs/?name="rpm:build" returns me the whole batch of jobs.

So what should I do to get only one job?

Upvotes: 3

Views: 7581

Answers (1)

Chris
Chris

Reputation: 200

can you pipe to JQ? as described from the cookbook:

https://github.com/stedolan/jq/wiki/Cookbook#filter-objects-based-on-the-contents-of-a-key

something like this:

curl -L gitlab.com/api/v4/projects/:proj_id/pipelines/:pipeline_id/jobs \
| jq -c '.[] | select(.name | contains("rpm:build"))'

Upvotes: 1

Related Questions