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.
-
Create a github token via https://github.com/settings/tokens with the scope of
repo
(see issue 13 for background). -
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=TOKEN=9e6eij3ckzvpe9mrhnqcis6zf8dhopmm46e3pi96 \
--env=PROVIDER=github \
--restart=always \
--name=converter meltwater/drone-convert-pathschanged
If you wish to use an enviroment file you can pass it when starting the container :
$ docker run -d \
...
--name=converter meltwater/drone-convert-pathschanged --envfile drone.env
- 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
-
Create a github token via https://your-github-server-address/settings/token with the scope of
repo
-
Create a shares secret:
$ openssl rand -hex 16
bea26a2221fd8090ea38720fc445eca6
- Download ran run the plugin:
$ docker run -d \
--publish=3000:3000 \
--env=DRONE_DEBUG=true \
--env=DRONE_SECRET=bea26a2221fd8090ea38720fc445eca6 \
--env=TOKEN=9e6eij3ckzvpe9mrhnqcis6zf8dhopmm46e3pi96 \
--env=PROVIDER=github \
--env=GITHUB_SERVER=https://your-github-server-address
--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
-
Create an "App password" via https://bitbucket.org/account/settings/app-passwords and select only "Read" under "Repositories"
-
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=BITBUCKET_USER=youruser \
--env=BITBUCKET_PASSWORD='yourpassword' \
--env=PROVIDER=bitbucket \
--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
-
Create a Stash access token via https://your-bitbucket-address/plugins/servlet/access-tokens/manage with read-only rights
-
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=TOKEN=9e6eij3ckzvpe9mrhnqcis6zf8dhopmm46e3pi96 \
--env=PROVIDER=bitbucket-server \
--env=STASH_SERVER=https://your-bitbucket-server-address
--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
-
Create a gitee token via https://gitee.com/personal_access_tokens with the scope of
repo
(see issue 13 for background). -
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=TOKEN=b4af6fc778a7aba5f2a133d155f5b4a9cbe7becb255557e67597a4967eb50a88 \
--env=PROVIDER=gitee \
--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
This extension uses doublestar for matching paths changed in your commit range, refer to their documentation for all supported patterns.
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
Same as above, but with an implicit include
:
---
kind: pipeline
name: readme
steps:
- name: message
image: busybox
commands:
- echo "README.md was changed”
when:
paths:
- README.md
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
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
The changeset is generated by comparing the list of files changed between the commit before the patch is applied and the commit after the patch is applied. As a result, the changeset for a commit may be different depending on which type of event triggered the build.
For example, the push
and tag
events may generate a changeset against the previous commit, where as the pull_request
event may generate a changeset against the source branch. For more specifics on how before and after are set, review the webhook parser.
Be careful when making empty commits with git commit --allow-empty
. When an empty commit is made, no files have changed, so this plugin will return the unmodified .drone.yml
back to the drone server process.
This can lead to potentially unexpected behavior, since any include
or exclude
rules will effectively be ignored.
There is a problem in the YAML library where ordering matters during unmarshaling, see #18
This syntax will fail:
anchor: &anchor
image: busybox
settings:
foo: bar
- name: test
<<: *anchor
when:
event: push
branch: master
But this will succeed:
anchor: &anchor
image: busybox
settings:
foo: bar
- <<: *anchor
name: test
when:
event: push
branch: master
Please read CONTRIBUTING.md to understand how to submit pull requests to us, and also see our code of conduct.
When this plugin is used in conjunction with protected repos, signature validation will frequently fail.
This occurs due to Drone's order of operations, in that the Drone file's signature is checked after the this plugin has rewritten sections based on the paths-changed triggers, resulting in a different signature for the file.