Merge pull request #14 from benschumacher/feature/skipverify
Add support for `skip_verify` in drone-webhook
This commit is contained in:
commit
d1cee2b37e
10
DOCS.md
10
DOCS.md
|
@ -1,10 +1,12 @@
|
|||
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:
|
||||
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`
|
||||
* `header` - HTTP request header map
|
||||
* `skip_verify` - Skip verification of TLS certificates, defaults to `false`
|
||||
|
||||
## Example
|
||||
|
||||
|
@ -23,10 +25,10 @@ notify:
|
|||
### Custom Body
|
||||
|
||||
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/)
|
||||
* `content_type` - HTTP request content type
|
||||
* `content_type` - HTTP request content type, defaults to `application/json`
|
||||
|
||||
Example configuration that generate a custom Yaml payload:
|
||||
|
||||
|
|
11
main.go
11
main.go
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
@ -108,7 +109,15 @@ func main() {
|
|||
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 {
|
||||
fmt.Printf("Error: Failed to execute the HTTP request. %s\n", err)
|
||||
|
|
1
types.go
1
types.go
|
@ -3,6 +3,7 @@ package main
|
|||
// Params represents the valid paramenter options for the webhook plugin.
|
||||
type Params struct {
|
||||
URLs []string `json:"urls"`
|
||||
SkipVerify bool `json:"skip_verify"`
|
||||
Debug bool `json:"debug"`
|
||||
Auth Auth `json:"auth"`
|
||||
Headers map[string]string `json:"header"`
|
||||
|
|
Loading…
Reference in New Issue