Creating webhooks
Gabriele Gallo Stampino avatar
Written by Gabriele Gallo Stampino
Updated over a week ago

Creating a webhook

You can create a webhook on the Project Settings page.

To create a webhook

  1. Go to your project (Repository or Environment)

  2. Settings

  3. Webhooks

  4. Add Webhook

  5. Configure an endpoint URL

  6. (Optional) Configure a Secret

  7. (If you want to broadcast events immediately) Activate the webhook

  8. And click Add Webhook

Events currently supported (JSON format)

  • Revision Scan (on branches)

  • Pull Request Scan

  • Diff Scan (available only when using the Copado integration)


Customize your webhook payload

Defaults can facilitate a quick start, but you may eventually need to create a tailored payload to send to your Webhook endpoint. A Custom Payload offers more flexibility useful for integrating Clayton with other systems.

You can configure two types of templates:

  • Sample

{
"event": "$event",
"data": {
"report_result": "$reportResult",
"report_url": "$reportHtmlUrl"
}
}
  • Copado DevOps Actions: RunJobTemplate

 {
"payload": {
"templateName": "My_Job_Template",
"runAfterInstantiation" : true,
"dataJson" : "$claytonEventPayloadStringified",
"preSteps" : [],
"postSteps" : [],
"additionalSteps" : []
}
}

Template Variables

Use Template Variables to customize your notification payloads. Commonly, these are used to pass dynamic values from an Attribute into the placeholders of a Template. A Template Variable can be referenced in any Template using the syntax $variableName.

Variable

Description

Value

claytonEventPayloadStringified

A variable that represents the entire Clayton event payload.

event

The event that generated the webhook.

PING, SCAN_READY, PR_READY, DIFF_READY

workspaceId

The Clayton Identifier of the workspace.

f123dd7f-9766-4i83-8760-9a0a28w51vb9

workspaceName

The Clayton workspace Name.

Acme Inc.

projectId

The Clayton Identifier of the project.

1f713e2d-bf75-4693-ab54-04aa159a7142

projectName

The Clayton project Name.

DevSecOps Repo

reportId

The Clayton Identifier of the scan report.

527b185d-d81d-41c2-9s7e-2c862ye063b4

reportResult

The result of the scan.

PASSED, PASSED_WITH_WARNINGS, NOT_PASSED

reportHtmlUrl

The Clayton report URL.

reportHtmlPullRequestId

The Clayton Identifier of the Pull Request. Available only for PR_READY and DIFF_READY events.

da40635c-8a5f-4775-bfd9-8bf34864d18e

reportHtmlPullRequestNumber

The external identifier of the Pull Request. Available only for PR_READY events.

12

claytonEventPayloadStringified example:

{
"payload": {
"templateName": "Clayton Test_1",
"runAfterInstantiation": true,
"dataJson": "{\"action\":{\"event\":\"DIFF_READY\"},\"workspace\":{\"id\":\"40c2cd-b2ec-407a-91a-7ca6d33122a\",\"name\":\"My awesome workspace\"},\"project\":{\"id\":\"06412-1b0-4669-af7c-fbead133deee\",\"name\":\"clayton demo\"},\"report\":{\"id\":\"06812-1bb0-4669-af7c-fbead1ee\",\"result\":\"NOT_PASSED\", \"html_url\":\"https://app.clayton.io/...\", \"pull_request_id\":\"068cb2-1bb0-4669-af7c-fbe33deee\"}}",
"preSteps": [],
"postSteps": [],
"additionalSteps": []
}
}


​
​


​

Did this answer your question?