Skip to content

Support 'ref' parameter in jobs api

What does this MR do and why?

Support ref parameter in jobs API.

The ref is an attribute of the jobs and also an attribute of the pipelines. The pipelines API already supports ref parameters, but the jobs API does not, it's a pity. 🥺

A more specific example: How can we get 100 jobs of the main branch through API?
Since the API does not support the ref parameter, we have to obtain results far exceeding 100 (In fact, we don't know how many jobs need to be obtained to be enough for 100 main jobs) through the jobs API, and then filter out other branches manually. 🥲

Screenshots or screen recordings

No UI changes.

How to set up and validate locally

curl --location --request GET 'http://127.0.0.1:3000/api/v4/projects/6/jobs?ref=main' \
--header 'PRIVATE-TOKEN: <YOUR-PRIVATE-TOKEN>'

Expected: the job.ref field in the return value is all "main"


cc @mtan-gitlab @zhendi

Edited by Zhiyuan Lu

Merge request reports