Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

GitLab CI "when: never" under "rules" doesn't stop pipeline from triggering

GitLab v. Enterprise Edition 15.0.5-ee
I have some stages defined and I need rules that would work like a conjunction.
But I have a problem that simply put:

rules:
 - if: ! A
   when: never
 - if: B

doesn’t work (like it should according to https://docs.gitlab.com/ee/ci/jobs/job_control.html):
it runs a pipeline despite (! A) being true

but

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

rules:
 - if: A && B

does work (pipeline doesn’t run). And second options is not preferable and in other case I have with exists it’s not possible (correct me if I’m wrong).

Is there a way to work around it?

EDIT 1:

ok I worked around the exists (checking if variable is null) part but I still want to have reusable code.

I’m using reference:

.rules:
  rules:
    - if: ! A
      when: never
    - exists:
        - "$ex"
      when: never

rules:
    - !reference [ .rules, rules ]
    - if: $var =~ /^.*abcd.*$/

because aliases and anchors don’t seem to work here. And if I want this structure then I figured that I need this when: never part for it to work. Therefore the original question about it. Without reference it doesn’t work either so it doesn’t matter unless I can do something to inject the rules in an if.

>Solution :

I think the boolean not operator does not exist, see this comment.
Try

rules:
 - if: A != true
   when: never
 - if: B
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading