mirror of
https://github.com/drone-plugins/drone-webhook.git
synced 2026-06-04 18:24:05 +08:00
Merge pull request #43 from drone-plugins/improve-config
Drop renovate, proper version definition, unified jsonnet config
This commit is contained in:
+12
-6
@@ -34,6 +34,12 @@ volumes:
|
||||
- name: gopath
|
||||
temp: {}
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/tags/**"
|
||||
- "refs/pull/**"
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: windows-1803
|
||||
@@ -48,7 +54,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.11-windowsservercore-1803
|
||||
commands:
|
||||
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/windows/amd64/drone-webhook.exe"
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-webhook.exe"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
@@ -61,7 +67,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.11-windowsservercore-1803
|
||||
commands:
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/windows/amd64/drone-webhook.exe"
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-webhook.exe"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
@@ -124,8 +130,8 @@ volumes:
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/pulls/**"
|
||||
- "refs/tags/**"
|
||||
- "refs/pull/**"
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
@@ -144,7 +150,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.11-windowsservercore-1809
|
||||
commands:
|
||||
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/windows/amd64/drone-webhook.exe"
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-webhook.exe"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
@@ -157,7 +163,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.11-windowsservercore-1809
|
||||
commands:
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/windows/amd64/drone-webhook.exe"
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-webhook.exe"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
@@ -220,8 +226,8 @@ volumes:
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/pulls/**"
|
||||
- "refs/tags/**"
|
||||
- "refs/pull/**"
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
|
||||
+15
-9
@@ -33,6 +33,12 @@ volumes:
|
||||
- name: gopath
|
||||
temp: {}
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/tags/**"
|
||||
- "refs/pull/**"
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: linux-amd64
|
||||
@@ -46,7 +52,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
commands:
|
||||
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-webhook"
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-webhook"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
@@ -59,7 +65,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
commands:
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/amd64/drone-webhook"
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-webhook"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
@@ -111,8 +117,8 @@ steps:
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/pulls/**"
|
||||
- "refs/tags/**"
|
||||
- "refs/pull/**"
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
@@ -130,7 +136,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
commands:
|
||||
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/drone-webhook"
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-webhook"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
@@ -143,7 +149,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
commands:
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm64/drone-webhook"
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-webhook"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
@@ -195,8 +201,8 @@ steps:
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/pulls/**"
|
||||
- "refs/tags/**"
|
||||
- "refs/pull/**"
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
@@ -214,7 +220,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
commands:
|
||||
- "go build -v -ldflags \"-X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm/drone-webhook"
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-webhook"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
@@ -227,7 +233,7 @@ steps:
|
||||
pull: always
|
||||
image: golang:1.11
|
||||
commands:
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}\" -a -o release/linux/arm/drone-webhook"
|
||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-webhook"
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
GO111MODULE: on
|
||||
@@ -279,8 +285,8 @@ steps:
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- "refs/pulls/**"
|
||||
- "refs/tags/**"
|
||||
- "refs/pull/**"
|
||||
|
||||
depends_on:
|
||||
- testing
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
Use the Webhook plugin to notify services via Webhook when a build completes.
|
||||
You will need to supply Drone with outgoing Webhook URLs.
|
||||
|
||||
You can override the default configuration with the following parameters:
|
||||
|
||||
* `urls` - JSON payloads are sent to each URL
|
||||
* `method` - HTTP request method. Defaults to `POST`
|
||||
* `headers` - HTTP request header map
|
||||
* `username` - The username as a string for HTTP basic auth
|
||||
* `password` - The password as a string for HTTP basic auth
|
||||
* `skip_verify` - Skip verification of TLS certificates, defaults to `false`
|
||||
|
||||
## Example
|
||||
|
||||
The following is a sample configuration in your .drone.yml file:
|
||||
|
||||
```yaml
|
||||
notify:
|
||||
webhook:
|
||||
urls:
|
||||
- https://your.webhook/...
|
||||
- https://your.other.webhook/...
|
||||
headers:
|
||||
- "Authorization=pa55word"
|
||||
```
|
||||
|
||||
### Custom Body
|
||||
|
||||
In some cases you may want to submit a custom payload in the body of your hook.
|
||||
For this usage the following additional parameters should be used:
|
||||
|
||||
* `template` - Handlebars template to create a custom payload body. See [docs](http://handlebarsjs.com/)
|
||||
* `content_type` - HTTP request content type, defaults to `application/json`
|
||||
|
||||
Example configuration that generate a custom Yaml payload:
|
||||
|
||||
TBD
|
||||
|
||||
### Basic Authentication
|
||||
|
||||
> It is important to note that with HTTP Basic Authentication the provided
|
||||
> username and password are not encrypted.
|
||||
|
||||
In some cases your webhook may need to authenticate with another service. You
|
||||
can set the basic `Authentication` header with a username and password. For
|
||||
these use cases we expose the following additional parameters:
|
||||
|
||||
* Sets the request's `Authorization` header to use HTTP Basic Authentication with the provided username and password below
|
||||
* `username` - The username as a string
|
||||
* `password` - The password as a string
|
||||
|
||||
Example configuration to include HTTP Basic Authentication:
|
||||
|
||||
```yaml
|
||||
notify:
|
||||
webhook:
|
||||
method: POST
|
||||
username: myusername
|
||||
password: mypassword
|
||||
urls:
|
||||
- https://tower.example.com/...
|
||||
```
|
||||
|
||||
### Debugging Webhooks
|
||||
|
||||
In some cases complicated webhooks may need debugging to ensure `urls`,
|
||||
`template`, `auth` and more a properly configured. For these use cases we expose
|
||||
the following `debug` parameter:
|
||||
|
||||
* `debug` - If `true` it will print out each URL request and response information
|
||||
|
||||
Example configuration to include the `debug` parameter:
|
||||
|
||||
```yaml
|
||||
notify:
|
||||
webhook:
|
||||
debug: true
|
||||
method: POST
|
||||
username: myusername
|
||||
password: mypassword
|
||||
urls:
|
||||
- http://tower.example.com/api/v1/job_templates/44/launch/
|
||||
- http://tower.example.com/api/v1/job_templates/45/launch/
|
||||
content_type: application/json
|
||||
```
|
||||
|
||||
|
||||
@@ -12,24 +12,31 @@ Drone plugin to send build status notifications via Webhook. For the usage infor
|
||||
|
||||
## Build
|
||||
|
||||
Build the binary with the following commands:
|
||||
Build the binary with the following command:
|
||||
|
||||
```
|
||||
go build
|
||||
```console
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
export CGO_ENABLED=0
|
||||
export GO111MODULE=on
|
||||
|
||||
go build -v -a -tags netgo -o release/linux/amd64/drone-webhook
|
||||
```
|
||||
|
||||
## Docker
|
||||
|
||||
Build the Docker image with the following commands:
|
||||
Build the Docker image with the following command:
|
||||
|
||||
```
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-webhook
|
||||
docker build --rm -t plugins/webhook .
|
||||
```console
|
||||
docker build \
|
||||
--label org.label-schema.build-date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
|
||||
--label org.label-schema.vcs-ref=$(git rev-parse --short HEAD) \
|
||||
--file docker/Dockerfile.linux.amd64 --tag plugins/webhook .
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
```
|
||||
```console
|
||||
docker run --rm \
|
||||
-e PLUGIN_URLS=https://hooks.somplace.com/endpoing/... \
|
||||
-e PLUGIN_HEADERS="HEADER1=value1" \
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
@@ -9,8 +8,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
version = "0.0.0"
|
||||
build = "0"
|
||||
version = "unknown"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -18,7 +16,7 @@ func main() {
|
||||
app.Name = "webhook plugin"
|
||||
app.Usage = "webhook plugin"
|
||||
app.Action = run
|
||||
app.Version = fmt.Sprintf("%s+%s", version, build)
|
||||
app.Version = version
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "method",
|
||||
|
||||
+11
-4
@@ -46,6 +46,13 @@ local golang_image(os, version) =
|
||||
volumes: volumes,
|
||||
},
|
||||
],
|
||||
trigger: {
|
||||
ref: [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
'refs/pull/**',
|
||||
],
|
||||
},
|
||||
volumes: [{name: 'gopath', temp: {}}]
|
||||
},
|
||||
|
||||
@@ -75,7 +82,7 @@ local golang_image(os, version) =
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/' + os + '/' + arch + '/' + name + extension,
|
||||
'go build -v -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" -a -tags netgo -o release/' + os + '/' + arch + '/' + name + extension,
|
||||
],
|
||||
when: {
|
||||
event: {
|
||||
@@ -92,7 +99,7 @@ local golang_image(os, version) =
|
||||
GO111MODULE: 'on',
|
||||
},
|
||||
commands: [
|
||||
'go build -v -ldflags "-X main.version=${DRONE_TAG##v} -X main.build=${DRONE_BUILD_NUMBER}" -a -o release/' + os + '/' + arch + '/' + name + extension,
|
||||
'go build -v -ldflags "-X main.version=${DRONE_TAG##v}" -a -tags netgo -o release/' + os + '/' + arch + '/' + name + extension,
|
||||
],
|
||||
when: {
|
||||
event: ['tag'],
|
||||
@@ -148,8 +155,8 @@ local golang_image(os, version) =
|
||||
trigger: {
|
||||
ref: [
|
||||
'refs/heads/master',
|
||||
'refs/pulls/**',
|
||||
'refs/tags/**',
|
||||
'refs/pull/**',
|
||||
],
|
||||
},
|
||||
depends_on: [test_pipeline_name],
|
||||
@@ -186,12 +193,12 @@ local golang_image(os, version) =
|
||||
},
|
||||
},
|
||||
],
|
||||
depends_on: depends_on,
|
||||
trigger: {
|
||||
ref: [
|
||||
'refs/heads/master',
|
||||
'refs/tags/**',
|
||||
],
|
||||
},
|
||||
depends_on: depends_on,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"docker": {
|
||||
"fileMatch": [
|
||||
"/docker/Dockerfile"
|
||||
]
|
||||
},
|
||||
"labels": [
|
||||
"renovate"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user