Predefined environment variables are not frozen throughout the same pipeline
Summary
Within the same pipeline, when the build job is working on the 1st job, and an update was made on the merge request, the subsequent job in the same pipeline will not have a consistent predefined environment variables
Take for instance CI_MERGE_REQUEST_TARGET_BRANCH_NAME
, if MR destination branch is changed while MR pipeline is running, subsequent jobs see a different value
The expectation: within the same pipeline, the value of variables should be the same
Steps to reproduce
- Have a pipeline with 2 stages.
- In a marge request pipeline:
- 1st stage job, print
CI_MERGE_REQUEST_TARGET_BRANCH_NAME
, then sleep for some time - 2nd stage job, print
CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- 1st stage job, print
- While the 1st stage is still running, update the MR into a new target branch
- 2nd stage job kicked off, the
CI_MERGE_REQUEST_TARGET_BRANCH_NAME
is different than the first one
Example Project
This bug happens on GitLab.com
- This is the pipeline: https://gitlab.com/awinata/issue-60911/pipelines/58171839
- Job1 target branch: master -> https://gitlab.com/awinata/issue-60911/-/jobs/201549632
- Job2 target branch: NewTargetBranch -> https://gitlab.com/awinata/issue-60911/-/jobs/201549633
- When Job 1 was running, the target branch in the MR was updated -> awinata/issue-60911!1
Initially reported in (internal only ZD) https://gitlab.zendesk.com/agent/tickets/119555)
Edited by Jackie Porter