Starting from Artifactory version 7.98.2, it is possible to set webhooks to trigger workers. This is useful in cases when you would like to configure workers to events that are not pre-configured in Workers, such as a Docker tag push.
For example, to set a worker that is triggered by a webhook whenever a Docker tag is pushed:
Create an HTTP-triggered worker and add your worker logic. You can build your JSON payload to get details about the event inside your worker code:
type DockerPushPayload = { "repo_key": string, "path": string, "name": string, "image_name": string, "tag": string } // This worker does something after a docker push export default async (context: PlatformContext, data: DockerPushPayload): Promise<any> => { console.log(data) return {}; }
Create a custom webhook with the following settings:
Field Name
Setting
Name
Enter a name for your webhook
URL
https://<your_instance_url>/worker/api/v1/execute/<your_worker_key>
Method
POST
Event
Select your event from the drop-down menu: for example, a Docker tag was pushed.
Secrets
Enter your token as a secret:
Name: “token”
Value: Enter a token with admin privilege
Headers
Enter these two headers:
Name: “Authorization”,
Value:
“Bearer {{.secrets.token}}”
Name: “Content-Type”,
Value:
“application/json”
Click Test on the Webhook page to verify that the webhook is triggering the worker as expected
Click Save. Now your worker will be triggered when a Docker tag is pushed.