I’ve been using Drone for a brief period of time now and am enjoying it a great deal, but I simply cannot figure out how to do the following:
- Trigger my test runs on pull request hooks.
- Trigger my test runs on push hooks from master only.
I gave the following a shot:
pipeline: test: image: node:latest commands: - npm install --no-optional --silent > /dev/null - npm run ci when: event: push branch: master when: event: pull_request
However this appears to ignore the first
I believe I’m looking for something like:
when: - branch == 'master' && event == 'push' - branch != 'master' && event == 'pull_request'
Looking through the docs at http://readme.drone.io/0.5/usage/conditional-builds/ and http://readme.drone.io/0.5/usage/conditional-build-steps/ I haven’t been able to figure out how to achieve what I need.
An initial workaround I used:
# first step of `test` - if [ "$DRONE_COMMIT_BRANCH" != master ] && [ "$DRONE_BUILD_EVENT" = push ]; then exit 0; fi
I’ve since dropped that workaround and now run with a duplicate
pipeline: test: when: branch: master event: push test: when: event: pull_request
This does indeed do the job, but I would love to scratch the duplication.