Drone plugin for triggering downstream builds with custom parameters
This plugin allows for triggering remote or local builds. You can specify
various filters, like tag
, branch
, number
, commit
, etc. It will find an
existing build which matches specified filters and trigger the build restart or
deployment, in addition, custom parameters can also be set.
Dependencies are located in the vendor directory and managed using govendor cli tool.
go test -v -cover
mkdir -p bin
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X main.Version=dev+git" -o bin/drone-trigger_linux_amd64
The following parameters are used to configure the plugin:
drone_server
: full URL to the drone server, it can be a remote drone server as welldrone_token
or${DRONE_TOKEN}
: drone user secret token. Just create aDRONE_TOKEN
secret, the plugin will pick it uprepo
: git repository in owner/name formatstatus
: build status filter, default issuccess
event
: build event type filter. If unset, no event filter will be donedeploy_to
: sends a deployment trigger, which also sets aDRONE_DEPLOY_TO
environment variable in the target jobparams
: list of custom parameters that will be passed into a build environment as environment variablesverbose
: displays a more verbose output
Only one filter from the below list can be specified.
number
: filter by specific build numbercommit
: filter by long commit shabranch
: filter by branch nametag
: filter by tag name. Please note that event type will betag
.deployed-to
: filter by the environment deployed to. Please note that event type will bedeployment
.
pipeline:
build:
image: golang
commands:
- go get -v
- ...
docker_build:
image: docker:1.11
commands:
- docker login ...
- docker build -t foo/bar:${DRONE_COMMIT_SHA} .
- docker push foo/bar:${DRONE_COMMIT_SHA}
trigger_deploy:
image: quay.io/ukhomeofficedigital/drone-trigger:latest
drone_server: https://drone.example.com
repo: owner/go-deploy-scripts
branch: master
deploy_to: prod
params: "IMAGE_NAME=foo/bar:${DRONE_COMMIT_SHA},APP_ID=123"
Since drone-trigger can be run as a standalone tool, configuration can be provided via cli flags and arguments as well as environment variables.
drone-trigger --help
NAME:
drone-trigger - trigger drone builds or deployments
USAGE:
drone-trigger_linux_amd64 [global options] command [command options] [arguments...]
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--verbose verbose output [$VERBOSE, $PLUGIN_VERBOSE]
--drone-server URL, -s URL drone server URL [$DRONE_SERVER, $PLUGIN_DRONE_SERVER]
--drone-token TOKEN, -t TOKEN drone auth TOKEN [$DRONE_TOKEN, $PLUGIN_DRONE_TOKEN]
--repo REPO, -r REPO REPO, eg. foo/bar [$REPO, $PLUGIN_REPO]
--commit value, -c value filter by commit sha [$FILTER_COMMIT, $PLUGIN_COMMIT]
--tag value filter by tag [$FILTER_TAG, $PLUGIN_TAG]
--branch value, -b value filter by branch [$FILTER_BRANCH, $PLUGIN_BRANCH]
--status value filter by build status (default: "success") [$FILTER_STATUS, $PLUGIN_STATUS]
--number value filter by build number (default: 0) [$FILTER_NUMBER, $PLUGIN_NUMBER]
--event value filter by trigger event [$FILTER_EVENT, $PLUGIN_EVENT]
--deploy-to value, -d value environment to deploy to, if set a deployment event will be triggered [$DEPLOY_TO, $PLUGIN_DEPLOY_TO]
--param value, -p value custom parameters to include in the trigger in KEY=value format [$PARAMS, $PLUGIN_PARAMS]
--help, -h show help
--version, -v print the version
Push / Merge to master will produce a docker
image with a tag latest
.
To create a new release, just create a new tag off master.
We welcome pull requests. Please check issues and existing PRs before submitting a patch.
Vaidas Jablonskis vaijab