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 HTMLminattribute 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
- Original issue: #421962
How to set up and validate locally
-
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.
-
With the setting left at the default
4, create a project with a.gitlab-ci.ymlthat declares 5 caches in a single job and confirm validation rejects it withno 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" -
Raise Maximum caches per job to
5and save. Re-validate the same config (CI Lint or pipeline editor) and confirm it now passes. -
Try entering
0in the field and confirm both browser and server-side validation reject the value.
Related to #421962