Display job metadata in CICD admin pages

What does this MR do and why?

Introduce read_build_metadata ability to grant users minimal read access to a build's information.

This ability can be granted to users to allow them to see minimal information about a build (e.g. duration, finished_at, id, etc.) even without membership to the build's project (membership grants read_build ability).

read_build_metadata is currently enabled for a user when any of the following conditions are met:

  • user can read_build
  • user can read_admin_cicd - purpose: in admin area, the user will be able to see minimal information of a build (of a project the user is not a member of)

References

Screenshots or screen recordings

Page User: Admin User: Non-admin w/ read_admin_cicd custom admin role
Admin Jobs page Note: Pointed elements are links Screenshot_2025-04-14_at_1.00.43_PM Note: Pointed elements are plain text Screenshot_2025-04-14_at_12.45.02_PM
Admin runner details page Screenshot_2025-04-14_at_1.03.15_PM Screenshot_2025-04-14_at_12.44.48_PM

How to set up and validate locally

  1. Enable feature flag

    $ rails c
    > Feature.enable(:custom_admin_roles)
  2. Create a new admin member role with read_admin_cicd permission enabled

    > admin_member_role = MemberRole.create(name: 'Test', description: 'Test', read_admin_cicd: true)
  3. Assign the new admin role to a non-admin user

    > user = User.find(<a_user_id>)
    > Users::UserMemberRole.create(member_role: admin_member_role, user: user)`
  4. Login with the user

  5. Click global search in left sidebar ("Search or go to"). Click "Admin area" menu item.

  6. In /admin/jobs page, find a job for a project the current user is not a member of

    Or, create one with the following commands in Rails console:
    > p = FactoryBot.create(:project, namespace: FactoryBot.create(:namespace, name: 'unique namespace name laksjdf'))
    > > FactoryBot.create(:ci_build, :success, project: p)
  7. Verify that the status, ref, and commit values are displayed as plain text instead of links

    Click to expand Screenshot_2025-04-14_at_12.45.02_PM
  8. Click on the job's runner to visit the runner details page. Click on Jobs tab then verify that the status, job, project, and commit columns values are displayed as plain text instead of links

    Click to expand Screenshot_2025-04-14_at_12.44.48_PM

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eugie Limpin

Merge request reports

Loading