A Drone conversion extension to include/exclude pipelines and steps based on paths changed.
Please note this project requires Drone server version 1.4 or higher.
Installation
-
Create a github token via https://github.com/settings/tokens with the scope of
repo:status
. -
Create a shared secret:
$ openssl rand -hex 16
bea26a2221fd8090ea38720fc445eca6
- Download and run the plugin:
$ docker run -d \
--publish=3000:3000 \
--env=DRONE_DEBUG=true \
--env=DRONE_SECRET=bea26a2221fd8090ea38720fc445eca6 \
--env=GITHUB_TOKEN=9e6eij3ckzvpe9mrhnqcis6zf8dhopmm46e3pi96 \
--restart=always \
--name=converter meltwater/drone-convert-pathschanged
- Update your Drone server configuration to include the plugin address and the shared secret.
DRONE_CONVERT_PLUGIN_ENDPOINT=http://1.2.3.4:3000
DRONE_CONVERT_PLUGIN_SECRET=bea26a2221fd8090ea38720fc445eca6
Examples
This extension uses doublestar for matching paths changed in your commit range, refer to their documentation for all supported patterns.
include
Only run a pipeline when README.md
is changed:
---
kind: pipeline
name: readme
trigger:
paths:
include:
- README.md
steps:
- name: message
image: busybox
commands:
- echo "README.md was changed”
Only run a pipeline step when README.md
is changed:
---
kind: pipeline
name: readme
steps:
- name: message
image: busybox
commands:
- echo "README.md was changed”
when:
paths:
include:
- README.md
include
and exclude
Run a pipeline step when .yml
files are changed in the root, except for .drone.yml
:
---
kind: pipeline
name: yaml
steps:
- name: message
image: busybox
commands:
- echo "A .yml file in the root of the repo other than .drone.yml was changed"
when:
paths:
include:
- "*.yml"
exclude:
- .drone.yml
depends_on
When using depends_on
in a pipeline step, ensure the paths
rules match, otherwise your steps may run out of order.
Only run two steps when README.md
is changed, one after the other:
---
kind: pipeline
name: depends_on
steps:
- name: message
image: busybox
commands:
- echo "README.md was changed”
when:
paths:
include:
- README.md
- name: depends_on_message
depends_on:
- message
image: busybox
commands:
- echo "This step runs after the message step"
when:
paths:
include:
- README.md