Artifactory introduced Custom Webhooks in version 7.55.2 (on-prem). This feature allows you to add a custom Payload that will be sent to the target service URL. There may be some required fields that the target service expects to receive in the JSON payload in order to successfully parse it. Slack, for instance, requires the “text” field to be included in the payload (more information can be found on Slack’s message payloads page).
In this example, we will create a simple webhook to a Slack channel that will be triggered whenever an artifact is deployed to a specific repository.
1. In the UI, navigate to Administration → General → Webhooks and create a new webhook.
2. Click on the “Custom” toggle on the right corner of the screen in order to create a custom webhook.
3. Provide the webhook’s URL. In this case, the Slack channel’s URL to which you would like to send the webhook. The URL structure should look similar to this:
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
More information can be found here.
4. Select the events that will trigger the webhook. In this example, we will create an event that will be triggered when an artifact is deployed to a specific repository.
5. Add the “Content-type: application/json” header:
2. Click on the “Custom” toggle on the right corner of the screen in order to create a custom webhook.
3. Provide the webhook’s URL. In this case, the Slack channel’s URL to which you would like to send the webhook. The URL structure should look similar to this:
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
More information can be found here.
4. Select the events that will trigger the webhook. In this example, we will create an event that will be triggered when an artifact is deployed to a specific repository.
5. Add the “Content-type: application/json” header:
6. Add the Payload content. For example:
{ "text": "{{.data.name}} was deployed to {{.data.repo_key}}/{{.data.path}}" }
7. Run the test connection to see that the configuration is valid.
Deploy an artifact to the specified repository to trigger the webhook. This is an example of the generated Slack message we configured in our Payload:
More information on the possible values to inject into the payload can be found in the Event Types section.