Skip to content

Fix merge request child pipelines

Fabio Pitino requested to merge fix-child-parent-pipeline-for-mr into master

What does this MR do?

Related to: #198594 (closed)

When using a merge request pipeline that creates child pipelines (see CI config below) the parent pipeline remains running and no child pipeline is created

workflow:
  rules:
    - if: $CI_MERGE_REQUEST_ID

child-1:
  trigger:
    include: child-1.yml

The bug was related to a missing merge_request object associated to the child pipeline, not passed in during the pipeline creation. Also we needed to allow a child pipeline to have a merge request object associated to it.

Changes

With this MR we are:

  1. changing the definition of merge request pipeline to rely solely on the presence of merge_request. This removes the existing strict validations on the presence/absence of merge_request object. These are anyway enforced at the application layer by MergeRequests::CreatePipelineService
  2. added Ci::Pipeline#merge_request? method and merged merge_request_event? and triggered_by_merge_request? into 1 SSOT method
  3. pass parent_pipeline.merge_request to child pipeline so that child pipelines also are merge request pipelines
  4. adjust specs due to the merge_request? refactoring

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Fabio Pitino

Merge request reports