Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion docs/services/webhook.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
## Configuration
# Webhook

The webhook notification service allows sending a generic HTTP request using the templatized request body and URL.
Using Webhook you might trigger a Jenkins job, update Github commit status.

## Parameters

The Webhook notification service configuration includes following settings:

- `url` - the url to send the webhook to
- `headers` - optional, the headers to pass along with the webhook
- `basicAuth` - optional, the basic authentication to pass along with the webook
- `insecureSkipVerify` - optional bool, true or false

## Configuration

Use the following steps to configure webhook:

1 Register webhook in `argocd-notifications-cm` ConfigMap:
Expand All @@ -21,6 +32,7 @@ data:
basicAuth: #optional username password
username: <username>
password: <api-key>
insecureSkipVerify: true #optional bool
```

2 Define template that customizes webhook request method, path and body:
Expand Down
9 changes: 5 additions & 4 deletions pkg/services/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ type BasicAuth struct {
}

type WebhookOptions struct {
URL string `json:"url"`
Headers []Header `json:"headers"`
BasicAuth *BasicAuth `json:"basicAuth"`
URL string `json:"url"`
Headers []Header `json:"headers"`
BasicAuth *BasicAuth `json:"basicAuth"`
InsecureSkipVerify bool `json:"insecureSkipVerify"`
}

func NewWebhookService(opts WebhookOptions) NotificationService {
Expand Down Expand Up @@ -154,7 +155,7 @@ func (r *request) execute(service *webhookService) (*http.Response, error) {

client := http.Client{
Transport: httputil.NewLoggingRoundTripper(
httputil.NewTransport(r.url, false),
httputil.NewTransport(r.url, service.opts.InsecureSkipVerify),
log.WithField("service", r.destService)),
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/services/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ func TestWebhook_SuccessfullySendsNotification(t *testing.T) {
defer server.Close()

service := NewWebhookService(WebhookOptions{
BasicAuth: &BasicAuth{Username: "testUsername", Password: "testPassword"},
URL: server.URL,
Headers: []Header{{Name: "testHeader", Value: "testHeaderValue"}},
BasicAuth: &BasicAuth{Username: "testUsername", Password: "testPassword"},
URL: server.URL,
Headers: []Header{{Name: "testHeader", Value: "testHeaderValue"}},
InsecureSkipVerify: true,
})
err := service.Send(
Notification{
Expand Down