Gitlab: Is there a way to limit the concurrency jobs in Gitlab by number?

Viewed 626

I have a Gitlab Runner running on Kubernetes. I see there are options to limit concurrent jobs from the runner level, but it would be preferable if we could do this in .gitlab-ci.yml level or from project level, but we can't we find the settings for it.

I saw this Disallow CI pipelines of one GitLab project to run concurrently? but I am also not sure how to do this on runner deployed on Kubernetes.

If I do this, it won't stop the runner from creating pods still which defeats the purpose of limiting concurrent jobs and control how much resources to be allocated.

I've also looked up resource_group but it limits the jobs to 1, but we want to limit the jobs to 2 or 3 to run concurrently.

1 Answers

Yes, there now is a way officially supported with GitLab 14.10 (April 2022):

CI/CD Limits set at the Instance Level

To contain resource usage in support of instance stability, GitLab administrators of instances with high CI/CD usage might want to add limits for specific CI/CD events.

This could be to set:

  • the maximum number of jobs in a single pipeline,
  • the maximum number of concurrent jobs in active pipelines, or
  • the maximum number of scheduled pipelines per project.
  • ...

GitLab instance administrators can now set these limits (and others) directly in the instance’s Admin Area panel.

See Documentation and Issue.

Related