Skip to content

Fix the problem of pipelines changes with external PRs [RUN ALL RSPEC] [RUN AS-IF-FOSS]

Furkan Ayhan requested to merge 208692-fix-modified-paths-of-external-prs into master

What does this MR do?

This MR fixes the problem of rules:changes / only:changes for external pull request pipelines.

Related to #208692 (closed) (also my comments: #208692 (comment 564926644), #208692 (comment 568113733))

The problem is about Ci::Pipeline#modified_paths because we check it while executing rules:changes and only:changes. The external PR is neither a merge_request? nor a branch_updated?. So it returns nil. Then satisfied_by? returns true when modified_paths is nil.

It's behind a feature flag ci_modified_paths_of_external_prs (#330605 (closed)).

Screenshots (strongly suggested)

Example CI Config

build:
  stage: build
  script: echo build

test1:
  stage: test
  script: exit 0
  only:
    refs:
      - external_pull_requests
    changes:
      - .gitlab-ci.yml

test2:
  stage: test
  script: exit 0
  only:
    refs:
      - external_pull_requests
    changes:
      - README.md

test3:
  stage: test
  script: exit 0
  only:
    refs:
      - external_pull_requests

test4:
  stage: test
  script: exit 0
  only:
    changes:
      - .gitlab-ci.yml

test5:
  stage: test
  script: exit 0
  only:
    changes:
      - README.md

Before this MR

Created PR

Screen_Shot_2021-04-30_at_18.09.17

GitLab CI is seen in the PR

Screen_Shot_2021-04-30_at_18.09.25

All jobs are run in the pipeline

Screen_Shot_2021-04-30_at_18.09.36

After this MR

Created PR

Screen_Shot_2021-04-30_at_18.08.21

GitLab CI is seen in the PR

Screen_Shot_2021-04-30_at_18.08.30

Jobs with changes:.gitlab-ci.yml are excluded from the pipeline

Screen_Shot_2021-04-30_at_18.08.46

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