I have simple pipeline that just triggers children pipelines based on changes. I would like to run specific child using gitlab.com page or through the API. For now I handle that with running parent pipeline for specific branch and manually stop all children pipelines but one
Right, so should it run trigger_a and trigger_b most of the time, but run trigger_a only when you start the pipeline via the API or have I misunderstood?
That pipeline works fine, now I seek for any legit way of running single trigger on specific branch.
Via the API, via the dashboard, via the hack, anything that is simpler than running full pipeline with run pipeline button in gitlab instance and manually disable all but one.
It’s still not quite clear to me what you want; but I think you just need to tweak the rules sections of your YAML config. Let’s imagine you don’t want trigger_b to run on the develop branch, you would add something like:
Unfortunately it doesn’t as it’s not that case. Let me describe scenario, so maybe things become more clear:
I make a commit that touch only a directory. Main pipeline runs, triggers only a/.gitlab-ci.yml. Everything is as expected. This commit is important for me so I tag it with XYZ
I do more commits that touches different things, every commit triggers main pipeline and corresponding children pipelines. So far so good.
Now I want to trigger ONLY trigger_a on XYZ tag. I go to dashboard → CI/CD → pipelines → Run pipeline, selecting tag XYZ and click Run pipeline. However it executes ALL triggers (trigger_a, trigger_b, trigger_c and so on). I need a way to run only child pipeline, not main.
Thank you a lot @snim2, it’s much closer to something I looked at and give me some options to achieve my goal. The problem with that solution is it’s hardcoded in pipeline (so if I decide to run only trigger_b it’s not possible with it).
Are you aware of possibilites of passing some variable during the web/api pipeline run? I could write a rule that depends on such variable, like
trigger_a:
stage: triggers
trigger:
include: a/.gitlab-ci.yml
strategy: depend
rules:
- if '$MY_VARIABLE is not null and $MY_VARIABLE != "trigger_a"'
when: never
- changes:
- a/**/*
trigger_b:
stage: triggers
trigger:
include: b/.gitlab-ci.yml
strategy: depend
rules:
- if '$MY_VARIABLE is not null and $MY_VARIABLE != "trigger_b"'
when: never
- changes:
- b/**/*