Skip to content

ci-package-builder: Ensure the freeze check is only done on MRs

Emanuele Aina requested to merge wip/em/fix-freeze-check-on-merge-requests into master

Commit dea8d068 switched the regex for the packaging branches from a literal to a variable to ease customization.

Accordingly to the documentation the behaviour should be the same: https://docs.gitlab.com/ee/ci/variables/README.html#storing-regular-expressions-in-variables

Unfortunately this seems to hit a bug when the variable to be matched is empty: when checking against a literal the check fails as expected, when checking against a variable it succeeds.

That is, if you have the rules below, only-on-mrs is executed on pipelines not tied to a MR, with $CI_MERGE_REQUEST_TARGET_BRANCH_NAME being empty.

only-on-mrs:
  script:
    - echo hello $CI_MERGE_REQUEST_TARGET_BRANCH_NAME!
  rules:
    - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ $BRANCH_REGEX
      when: always
    - when: never

only-on-mrs-but-with-a-literal-regex:
  script:
    - echo hello $CI_MERGE_REQUEST_TARGET_BRANCH_NAME!
  rules:
    - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ /^master$/
      when: always
    - when: never

Work around this by explicitly checking for a merge request.

Signed-off-by: Emanuele Aina emanuele.aina@collabora.com

Merge request reports