How to only trigger on changes to specific file(s)

Drone has several conditions to trigger off. Is there one that will trigger off changes to specific files or dirs ? Main example would be to NOT trigger when README.md is changed, only when the main repo files change.

Using gitlab only: changes: type syntax maybe ?

Very annoying to have a pipeline run when a 2-word change to README.md is pushed.

1 Like

Hi @Halfwalker!
All Drone triggers are content-independent. As a workaround you may use exit 78 command to exit your pipeline stages before compilation steps. Here is an example:

---
kind: pipeline
type: docker
name: default

steps:
- name: trigger
  image: plugins/git
  commands:
  - test $DRONE_BUILD_EVENT = pull_request
    && DIFF_STRING=origin/${DRONE_COMMIT_BRANCH:-master}
    || DIFF_STRING=${DRONE_COMMIT_SHA}~
  - git --no-pager diff --name-only $DIFF_STRING
    | grep -q -e ^[.]drone[.] -e ^Makefile$ -e [.]c$
    || exit 78

- name: build
  image: gcc
  commands:
  - make

- name: test
  image: gcc
  commands:
  - ./test

...

If you want to limit pipeline or pipeline step execution based on files changed, you can install an extension for this. See https://github.com/meltwater/drone-convert-pathschanged

Yeah, I saw that, thanks. Unfortunately it does’t support Gitea (yet).