Search code examples
gitlabgitlab-cigitlab-pipelines

How not to run pipelines on specific commit message


I have pipeline that makes some changes and commits another change which triggers another pipeline and I dont want that automatic update to trigger pipeline.

I had an idea that I will specify commit message and that ignore it, but for some reason I cannot get it working.

Can you help me with that?

variables:
  COMMIT_MESSAGE: "MyCommitMessage"

workflow:
  rules:
    - if: $CI_COMMIT_MESSAGE != $COMMIT_MESSAGE
...

Solution

  • You have to add the never keyword and use a regex like this :

    variables:
      COMMIT_MESSAGE: "MyCommitMessage"
    
    workflow:
      rules:
        - if: $CI_COMMIT_MESSAGE =~ /^.*COMMIT_MESSAGE/
          when: never
        - when: always
    

    The if will be evaluate to true and the pipeline will never run.