How to skip running Gitlab Pipeline when specific files change.

In some cases you might not want to run the pipeline when specific files change. For example there is no need to run the pipeline if you update only the README.md file in the repository. There is a built in function to do this called “except” the following example will show how to use it.

apply:
  stage: apply
  when: manual
  script:
    - terraform apply -auto-approve
  except:
    changes:
      - README.md
  dependencies:
    - validate and review

In the above exampe we skip running the apply job when the README.md changes. Please note that this has to be defined in EACH job you have in the pipeline configuration.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.