Issue with triggering downstream pipeline in multi-project setup using API calls
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
Triggering pipelines with API using official documentation doesn't seem to work.
Steps to reproduce
We are able to POST API calls using below command via CLI but doesnt work in CI.yml. Error "Reference not found". We are unable to pass variables in anyway either.
curl --request POST \ "https://gitlab.com/api/v4/projects/PROJECTID/trigger/pipeline?token=TOKEN&ref=master"
From official guide in Pipeline Trigger section in Settings >> CI/CD, the below format should work. It doesnt work either in curl or CI.YML.
curl --globoff --request POST --header "PRIVATE-TOKEN: TOKEN" \ "https://gitlab.com/api/v4/projects/PROJECTID/trigger/pipeline?ref=master"
Parent YML
Trigger job test:
stage: validate
script:
- curl --request POST \ "https://gitlab.com/api/v4/projects/PROJECTID/trigger/pipeline?token=TOKEN&ref=BRANCH"
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "BRANCH"'
OR
Trigger job test:
stage: validate
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "BRANCH"'
trigger:
include:
- project: PROJECTB-PATH
file: .gitlab-ci.yml
ref: BRANCH
strategy: depend
Example Project
What is the current bug behavior?
- Create a PROJECT A and PROJECT B, so that Merge event in Project A triggers pipeline in Project B.
- Merge request kicks off a Pipeline for Merged Results
- A bridge job starts in this Pipeline for Merged Results due to presence of a
trigger:type job or due to cURL API in script block. - The bridge job fails to create pipeline "downstream pipeline can not be created".
- The bridge job's error message indicates "Reference not found".
- Executing curl in CLI works and triggers pipeline in Project B, but doesnt work in YML. Unable to pass variables.
What is the expected correct behavior?
Should be able to pass variables and trigger downstream pipeline.
Relevant logs and/or screenshots
Environment info
Self-hosted GitLab Enterprise Edition 14.2.1-ee
++ Support request filed https://support.gitlab.com/hc/en-us/requests/255875