I was reading Downstream pipelines | GitLab
I couldn’t find a way to trigger one specific job from my project to another project.
trigger:
project: myproject/myrepo/.gitlab-ci.yaml
branch: main
strategy: depend
I can use above to create my downstream pipeline but this triggers all the job. If I have lets say 3 jobs here then I just want to trigger one job.
botkero
2
As far as I see, trigger
does have no option to specify one job.
So you would have to use rules
plus CI_PIPELINE_SOURCE
.
e.g., for myproject/myrepo/.gitlab-ci.yaml
:
my-job:
script:
- echo "Hello World"
rules:
- if: $CI_PIPELINE_SOURCE == "parent"
my-build:
script:
- echo "Hello GitLab
- If you run this inside
myproject
, then only my-build
will be executed.
- If you run this via a
trigger
, then only my-job
gets executed.
Hopefully, that will help you out.