Skip to main content
Creating webhooks
Gabriele Gallo Stampino avatar
Written by Gabriele Gallo Stampino
Updated over 7 months 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

Currently Supported Events (JSON format)

  • Revision Scan (on branches)

  • Pull Request Scan

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

Payload Examples

Pull Request Scan

{
"action": {
"event": "PR_READY"
},
"workspace": {
"id": "f119dd7f-4e83-8760-9a0a28e80bb9",
"name": "Clayton"
},
"project": {
"id": "23567bad-879f-8ae5-a45366489306",
"name": "sfdx-demo"
},
"report": {
"id": "99806a43-4159-8a59-d66832614f09",
"pull_request_id": "dfa2-4546-a255-9d1c4952f3c6",
"pull_request_number": 390,
"result": "NOT_PASSED",
"html_url": "https://app.clayton.io/repositories/23567bad-4b31-8ae5-a45366489306/pr-issues/-dfa2-9d1c4952f3c6",
"from_revision": {
"sha": "8d4ad16b7996316d24e2c9",
"short_sha": "8dd1",
"comment": "testing limit 20",
"author": "test@clayton.io",
"branch_name": "-inline-"
},
"to_revision": {
"sha": "777e9c811ac0e85650d4d48f8e768fa8d",
"short_sha": "779c8",
"comment": "wip",
"author": "test@clayton.io",
"branch_name": "master"
}
}
}

Revision Scan (on branches)

{
"action": {
"event": "SCAN_READY"
},
"workspace": {
"id": "f119dd7f-4e83-8760-9a8e80bb9",
"name": "Clayton"
},
"project": {
"id": "23567bad-4b31-8ae5-a453664306",
"name": "sfdx-demo"
},
"report": {
"id": "9b3cbbe0-80a7-4c8b77704",
"result": "NOT_PASSED",
"html_url": "https://app.clayton.io/repositories/23567bad-4b31-8ae5/issues/9b3cbbe0-4c8b12777704",
"revision": {
"sha": "777e9c811ef650d4d48f68fa8d",
"short_sha": "7c8",
"comment": "wip\n",
"author": "test@clayton.io"
}
}
}


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?