stop trying to bridge pipelines and make it one pipeline. Keep the building job unconditional so it runs on main too, and gate only the deploying job with rules on the main branch. Then pass data with normal artifacts and variables inside that single pipeline run. If you truly need state to survive across pipelines, write it somewhere durable instead: push the version file as a pipeline artifact and fetch it via the API, or tag the commit and read the tag. But for build-then-deploy, the single pipeline with a gated deploy job is the right shape, and it removes the race where the main branch changed between the MR build and the deploy.