CI_PIPELINE_SOURCE set to unexpected values when triggering a pipeline from a job
What is/are the relevant URLs or emails?
https://docs.gitlab.com/ee/ci/triggers/README.html#when-used-with-multi-project-pipelines
Briefly describe the bug
The documentation says that CI_PIPELINE_SOURCE=pipeline
when triggering pipelines through a job.
Our pipeline was seeing this behavior for the past few weeks, but earlier today the variable changed to CI_PIPELINE_SOURCE=cross_project_pipeline
which spawned thousands of pipelines in our production project. This led to thousands of Gitlab minutes being spent on our company account.
We wanted to bring this to your attention, since the documentation is going to cause the same problems for anyone else who try to use this multiple pipelines feature.
For context on the use-case, we tried to run the trigger jobs except when CI_PIPELINE_SOURCE=pipeline
. This is what our job looks like:
trigger:
stage: Trigger production pipelines
image: curlimages/curl:latest
script:
- curl --request POST
--form "token=$CI_JOB_TOKEN"
--form ref=master
"https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/trigger/pipeline"
except:
variables:
- $CI_PIPELINE_SOURCE == "pipeline"
What are the steps to reproduce the bug
- Trigger a pipeline with a job via the
curl
command - Check the value of
CI_PIPELINE_SOURCE