Add support for `skip_verify` in drone-webhook

This commit is contained in:
Ben Schumacher 2016-05-11 16:03:40 -06:00
parent da3069732d
commit eb298bafe6
3 changed files with 17 additions and 5 deletions

10
DOCS.md
View File

@ -1,10 +1,12 @@
Use the Webhook plugin to notify services via Webhook when a build completes. 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 You will need to supply Drone with outgoing Webhook URLs.
default configuration with the following parameters:
You can override the default configuration with the following parameters:
* `urls` - JSON payloads are sent to each URL * `urls` - JSON payloads are sent to each URL
* `method` - HTTP request method. Defaults to `POST` * `method` - HTTP request method. Defaults to `POST`
* `header` - HTTP request header map * `header` - HTTP request header map
* `skip_verify` - Skip verification of TLS certificates, defaults to `false`
## Example ## Example
@ -23,10 +25,10 @@ notify:
### Custom Body ### Custom Body
In some cases you may want to submit a custom payload in the body of your hook. In some cases you may want to submit a custom payload in the body of your hook.
For the use case we expose the following additional parameters: For this usage the following additional parameters should be used:
* `template` - Handlebars template to create a custom payload body. See [docs](http://handlebarsjs.com/) * `template` - Handlebars template to create a custom payload body. See [docs](http://handlebarsjs.com/)
* `content_type` - HTTP request content type * `content_type` - HTTP request content type, defaults to `application/json`
Example configuration that generate a custom Yaml payload: Example configuration that generate a custom Yaml payload:

11
main.go
View File

@ -2,6 +2,7 @@ package main
import ( import (
"bytes" "bytes"
"crypto/tls"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
@ -108,7 +109,15 @@ func main() {
req.SetBasicAuth(vargs.Auth.Username, vargs.Auth.Password) req.SetBasicAuth(vargs.Auth.Username, vargs.Auth.Password)
} }
resp, err := http.DefaultClient.Do(req) client := http.DefaultClient
if vargs.SkipVerify {
client = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
}
resp, err := client.Do(req)
if err != nil { if err != nil {
fmt.Printf("Error: Failed to execute the HTTP request. %s\n", err) fmt.Printf("Error: Failed to execute the HTTP request. %s\n", err)

View File

@ -3,6 +3,7 @@ package main
// Params represents the valid paramenter options for the webhook plugin. // Params represents the valid paramenter options for the webhook plugin.
type Params struct { type Params struct {
URLs []string `json:"urls"` URLs []string `json:"urls"`
SkipVerify bool `json:"skip_verify"`
Debug bool `json:"debug"` Debug bool `json:"debug"`
Auth Auth `json:"auth"` Auth Auth `json:"auth"`
Headers map[string]string `json:"header"` Headers map[string]string `json:"header"`