Ci::Build#merge_request is nil in MR pipelines
I'm attempting to use the new $CI_MERGE_REQUEST_CHANGED_PAGE_*
CI variables and am unable to. I suspect this is because the builds in a merge request pipeline are not correctly detecting the merge request, but I'm not sure why.
gitlab.com reproduction
- Branch w/ open MR: pipeline and job
- Detached MR pipeline: pipeline and job
- Pipeline for merged results: pipeline and job
Local reproduction
pry(main)> Ci::Pipeline.find(69).builds.map(&:has_environment?)
=> [false, true, true, false]
pry(main)> Ci::Pipeline.find(69).builds.map { |build| build.merge_request.present? }
=> [false, false, false, false]
I'm filing this as a bug because it's at least counter-intuitive that a pipeline for a merge request has builds with no merge request, and it does seems like an actual bug with how we detect merge requests from builds. My gut feeling is that MergeRequest-Ci::Pipeline architecture has changed, and Ci::Build#merge_request
hasn't kept up.
Merge request originally implementing the build variables relying on merge_request
and environment
: !25256 (merged)
Edited by drew stachon