Exporting all jobs at the Instance into JSON or CSV

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem


The https://{hostname}/admin/jobs page shows the all jobs across the instance. However, this page does not have a feature to export them. Also, there are no such REST API that returns the same information in this page.

At times, a customer (especially in financial industry) need to check how the jobs are working or report it to the government.

Proposal


  • Add "Export as CSV" button in there.
  • Implement the new REST API for Administrator that returns all jobs across the instance

Workaround


Querying DB directly. For example:

SELECT cb.status,
cb.name,
CONCAT('#', cb.id, ' ', cb.ref, ' ', LEFT(cp.sha,8)) AS "job",
CONCAT('#', cb.commit_id, ' by ', u.username) AS "pipeline",
p.name AS "project",
CASE WHEN cr.id IS NULL THEN 'none' ELSE CONCAT(cr.description, '#', cr.id) END AS "runner",
cb.stage,
cb.finished_at
FROM       ci_builds cb
INNER JOIN ci_pipelines cp    ON cb.commit_id = cp.id
INNER JOIN users u            ON cp.user_id = u.id
INNER JOIN projects p         ON cp.project_id = p.id
LEFT OUTER JOIN ci_runners cr ON cb.runner_id = cr.id
ORDER BY cb.id desc;

ZD Internal: https://gitlab.zendesk.com/agent/tickets/489176

Edited by 🤖 GitLab Bot 🤖