Hey everyone, I have a question about GitLab pipelines. Is it possible for one pipeline to wait for another pipeline to finish? We have several repositories (three in this case) and their pipelines tend to interfere with one another, especially during deployment to a server. The aim is for the pipeline to be aware if a specific other pipeline is running. Is there a way to achieve this in GitLab? Also, we would prefer to keep using concurrent runners, so just tagging a single runner isn't really an option we want to pursue.
5 Answers
You could definitely use the GitLab API with an access token to check if a specific pipeline is finished. You'd loop through this check until the pipeline in your targeted project completes. Alternatively, consider running multi-project pipelines, which could simplify the process without too much hassle.
Why not just combine everything into a single pipeline if you need them to run sequentially? Does it take a long time to execute? It might save you some trouble!
Have you considered using resource groups? If you assign the same resource group to the deploy stage across your pipelines, only one deployment job will run at a time across them. This could help manage concurrency effectively.
As far as I know, it’s not straightforward. I recall reading an article where someone managed to control pipelines through scripts. You might want to check that out. Just remember that each pipeline runs in its own environment, so you might have to rethink your approach if they are merely building libraries or static assets.
GitLab has a cool feature for this called downstream pipelines. You can trigger other repositories' pipelines from the first one, making the second dependent on the first to finish. This feature not only keeps your pipelines organized but also lets you see the entire process in one go, which is super helpful.

That's really nice to know! I wish GitHub had something similar for visualizing downstream pipelines.