'How to combine GitLab CI job for rule:if with matrix and allow_failure?
I need configure my GitLab CI job like this:
- Only job with
$CI_PIPELINE_SOURCE == "merge_request_event"is added to Pipeline, - Job is runned multipletimes by
matrixfor each version defined by matrixPHP_VERSION: [ '7.4', '8.0', '8.1' ]. - The
'8.1'must but runned withallow_failure: true.
I tried to write rules intuitive as I except rules works, but I'm getting a different result.
I first tried this:
parallel:
matrix:
- PHP_VERSION: [ '7.4', '8.0', '8.1' ]
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: on_success
- if: '$PHP_VERSION == "8.1"'
allow_failure: true
It result only to MR event for PHP 8.1 us added to Pipeline.
My next iteration is still wrong:
parallel:
matrix:
- PHP_VERSION: [ '7.4', '8.0', '8.1' ]
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: on_success
- if: '$PHP_VERSION == "8.1"'
when: on_success
allow_failure: true
- when: on_success
This looks better, but it runs job for every other event (not only merge_request_event).
How I can to right combine rules to get result as I declared above? 🙏
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
