HelmBurger
HelmBurger

Reputation: 1298

Running one pipeline at a time in Gitlab runner

I have a Private Gitlab runner that I use for running following stages in my pipeline:

  1. vm-start
  2. test
  3. build
  4. deploy
  5. vm-stop

vm-start and vm-stop stages are used to start and stop another Runner VM in Azure, which is responsible for running test, build and deploy stages (flow which I control via tags)

The issue I'm facing is when 2 pipelines are triggered at the same time on the same runner. First pipeline might be shutting down the VM where the second pipeline is still on testing stage. This ultimately results in second pipeline getting failed.

I tried looking into concurrency option but that is only at a job level. I'm ideally looking to run only 1 pipeline at a time and queue the others. Only when first pipeline is finished completely should the second pipeline start. How can I achieve this?

Upvotes: 1

Views: 523

Answers (1)

The DevOps Dude
The DevOps Dude

Reputation: 1937

To ensure only one pipeline runs at a time in GitLab and queue others, you can use the resource_group attribute in your .gitlab-ci.yml file. For instance, you can assign all jobs in your pipeline to the same resource_group. This configuration makes GitLab run only one set of jobs (e.g., vm-start, test, build, deploy, vm-stop) at any given time for that resource group. If another pipeline is triggered while one is already running, it will automatically queue until the running pipeline finishes. You can look further into resource groups here

Upvotes: 1

Related Questions