Skip to content

Allow use of `when` with `rules`

Laura Montemayor requested to merge lm-add-support-for-when-rules into master

What does this MR do and why?

Allows the use of when with rules.

Note: This is NOT a breaking change as it's not changing the existing functionality, it is a feature enhancement.

Screenshots or screen recordings

Screen_Shot_2021-12-06_at_5.44.27_PM

How to set up and validate locally

Test with any of the following config files.

          job-with-rules:
            script: 'echo hey'
            rules:
              - if: $CI_COMMIT_REF_NAME =~ /master/

With a matching rule: when: on_success

          job-when-with-rules:
            script: 'echo hey'
            when: manual
            rules:
              - if: $CI_COMMIT_REF_NAME =~ /master/

With a matching rule: when: manual

          job-when-with-rules-when:
            script: 'echo hey'
            when: manual
            rules:
              - if: $CI_COMMIT_REF_NAME =~ /master/
                when: on_success

With a matching rule: when: on_success

          job-with-rules-when:
            script: 'echo hey'
            rules:
              - if: $CI_COMMIT_REF_NAME =~ /master/
                when: manual

With a matching rule: when: manual

          job-without-rules:
            script: 'echo this is a job with NO rules'

With a matching rule: when: on_success

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

#219437 (closed)

Edited by Laura Montemayor

Merge request reports