Reputation: 198
I am trying to trigger a pipeline from another pipeline using '$CI_JOB_TOKEN' (https://docs.gitlab.com/ee/ci/triggers/README.html#when-used-with-multi-project-pipelines). The second pipeline is getting triggered, but it is always executing the build stage of the second pipeline. Which means it is only executing those jobs with 'except: - triggers'. I wanted to execute jobs with 'only: -triggers'
trigger-child-pipeline:
stage: trigger-child-pipeline
only:
- triggers
tags:
- runner
script:
- curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=my_branch https://gitlab.mycompany.com/api/v4/projects/1234/trigger/pipeline
I wanted to execute jobs with 'only trigger' tag in the child pipeline. Am I missing anything? I couldnt figure out anything from the documentation(https://docs.gitlab.com/ee/ci/triggers/README.html#when-used-with-multi-project-pipelines).
Thanks
Upvotes: 2
Views: 2677
Reputation: 1323943
Try again with GitLab 13.4 (September 2020)
You can check if its latest feature will make your use-case easier, with a different approach:
Child pipelines can now trigger their own child pipelines
When using parent/child pipelines, it is now possible for child pipelines to trigger their own child pipelines. This added depth can be useful when you want the flexibility to generate a variable number of child pipelines.
Before, with a parent/child configuration, every child pipeline needed a trigger job manually defined in the parent.
Now you can generate child pipelines that dynamically trigger any number of new child pipelines. If you have a monorepo, for example, you can dynamically generate a first child pipeline that itself generates a variable number of new child pipelines, based on the changes in a branch.
See Documentation and Issue.
Upvotes: 2