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
  • 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

Initially reported in (internal only ZD) https://gitlab.zendesk.com/agent/tickets/119555)

Edited by 🤖 GitLab Bot 🤖