how to trigger a downstream pipeline on a tagged branch in gitlab multi project pipeline?

Viewed 354

I would like to trigger a GitLab project, but instead of using a branch, I would like to use a specific tag. How can this be achieved?

The following triggers the develop branch of some-project:

bridge:
  stage: bridge
  trigger:
    project: some-project
    branch: develop
2 Answers

You can use the parent-child pipeline feature with the ref keyword, like this:

bridge:
  stage: bridge
  trigger:
    include:
      - project: some-project
        ref: 'your-tag'
        file: '.gitlab-ci.yml'

You can trigger the pipeline using the API.

Example using a curl command, which you can add to your job script:

curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=my-tag \
  https://gitlab.example.com/api/v4/projects/6/trigger/pipeline

When you use the CI_JOB_TOKEN to trigger pipelines, GitLab recognises the source of the job token. The pipelines become related, so you can visualise their relationships on pipeline graphs.

Related