Search code examples
gitlab-ciworkflowrules

Gitlab CI pipeline does not run with workflow rule set


Sorry for my rusty english...

I have this simple pipeline to test the workflow keyword with rules:

image: docker:rc-dind

stages:
  - build-socle

workflow:
  rules:
    - changes:
        - "!/README.md"
      when: always

build-socle:
  stage: build-socle
  script:
    - echo "Lancement de la construction de l'image socle"

What i understand is that the pipeline should start for any modified files except README.md

i tried changing a file `myscript.sh' in the project, but the pipeline did not start...

Any suggestions why ?


Solution

  •     - changes:
            - "!/README.md"
    

    Unfortunately, the ! glob metacharacter is not supported in Ruby's fnmatch, therefore it is unsupported for use with rules:changes:. As mentioned in the docs, you can only use syntax supported by Ruby's fnmatch.

    You can, however, formulate an equivalent negation without the use of the metacharacter:

    rules:
      changes:
      - '**/{[^R]*,R,R[^E]*,RE,RE[^A]*,REA,REA[^D]*,READ,READ[^M]*,READM,READM[^E]*,README,README[^.]*,README.,README.[^m]*,README.m,README.m[^d]*,README.md?*}'
    

    And this should work as expected (with the caveat that files named README.md in other directories will also be ignored).