Make CI cache limit per job configurable by admins

What does this MR do and why?

Replaces the hardcoded MULTIPLE_CACHE_LIMIT = 4 in Gitlab::Ci::Config::Entry::Caches with a new ci_max_caches_per_job application setting, so instance administrators can raise the limit when their use case requires more than four cache: entries in a single CI/CD job.

  • Default: 4 — preserves existing behavior on every instance.
  • Minimum: 1 — enforced by model validation (numericality: { only_integer: true, greater_than: 0 }) and the HTML min attribute on the input.
  • Where: Admin Area → Settings → CI/CD → Continuous Integration and Deployment → Maximum caches per job.

The setting reuses the existing ci_cd_settings_definition JSONB column, so no database migration is required. GitLab.com is unaffected unless an admin explicitly changes the value.

References

How to set up and validate locally

  1. As an admin, visit Admin Area → Settings → CI/CD and expand Continuous Integration and Deployment. Confirm a new Maximum caches per job field appears below Maximum includes.

  2. With the setting left at the default 4, create a project with a .gitlab-ci.yml that declares 5 caches in a single job and confirm validation rejects it with no more than 4 caches can be created:

    test:
      cache:
        - { key: a, paths: [a/] }
        - { key: b, paths: [b/] }
        - { key: c, paths: [c/] }
        - { key: d, paths: [d/] }
        - { key: e, paths: [e/] }
      script: echo "hello"
  3. Raise Maximum caches per job to 5 and save. Re-validate the same config (CI Lint or pipeline editor) and confirm it now passes.

  4. Try entering 0 in the field and confirm both browser and server-side validation reject the value.

Related to #421962

Edited by Avielle Wolfe

Merge request reports

Loading