How to prevent parallel runs on an entire pipeline

I have a pipeline that has two stages, as well as one gitlab runner that I installed on a centos 7 server. Whenever I have two separate repos, and make a commit at the same time with the gitlab cicd file, they both kick off the pipeline. Whichever one was first actually runs the pipeline and the other one is stuck in the pending state. This is good, and is what I want to happen. Whenever the first stage completes for the first repo, it moves on to the second stage. The second repo moves out of the pending state and starts running the first stage. I believe this is expected and default behavior, but that is not good behavior for me. Is there any possible way to make sure that the centos 7 runner forces any pending runs of the pipeline to wait until all stages are completed?

I have played with the idea of having only one stage, but I absolutely must have two stages, as this second stage is configured to run always, even upon failure of the first stage.

Perhaps if there is some option that allows you to always run a set of commands at the end of the stage, that would help me avoid this issue entirely.

I don’t think there’s a way of “force-this-whole-pipeline-to-complete-before-moving-to-next-one”.
The whole CI is working off a queue of “jobs” or “jobs-in-pipelines”. So the jobs are queued independently no matter from which pipeline they originate from.

I have no clue how your runners’ setup, but if you’re not using it yet, I suggest you setup a few docker runners and use them when possible (you can not use docker when working with systemd for example - well you can but you have to run the containers with superuser perms, etc…)

By running multiple docker runners at once on the same VM, you can have - makes sense - more jobs being run at once. For example Webpack bundling (webdev related) or maybe some dependency checks can be all done in separate jobs in containers.


Anyhow, I’ve written more than needed. I hope I’ve re-explained the problem you’re having well enough.
If you need any more info, please do ask.

Yes I would like to get some more runners soon. I just made one stage and used the after_script parameter, which suits my purposes for now. I also read about resource groups, and I think that may also be a solution, but I need to upgrade gitlab to get that feature. Thanks for taking the time to reply.