Configuring webhooks for your project
Webhooks notify external services when a SonarQube Cloud project analysis is complete.
This page describes how to manage webhooks for your SonarQube Cloud project. For more information about the feature, see Webhooks. You must be a project admin to be able to manage webhooks for your project.
Creating a webhook
This paragraph explains how to create webhooks in the UI for your project. You can also use the Web API.
To create a webhook for your project:

Retrieve your project. For more information, see Retrieving projects.
Go to Administration > Webhooks.
Select Create. The Create Webhook dialog is displayed.
Enter the webhook name.
Enter the URL to which the webhook is to be delivered.
Enter a secret if you want to protect the webhook with HMAC. See Securing webhooks below.
Test your webhook. To do so, you can use various webhook testing/debugging tools.
Updating or deleting a webhook
Retrieve your project. See Retrieving projects for details.
Go to Administration > Webhooks.
Use the action menu on the right side of the row to Update or Delete the webhook.
Monitoring the webhook delivery
You can monitor the delivery of your webhooks configured for your project in the SonarQube UI. You can also use the Web API to retrieve the webhook deliveries.
Each webhook’s delivery status is indicated. A delivery is marked as failed if the URL does not respond within 10 seconds. Response records are purged after 30 days.
To monitor your project's webhooks:
Retrieve your project. See Retrieving projects for more information.
Go to Administration > Webhooks. The page shows the result and timestamp of each webhook’s most recent delivery.
To view the payload of the last delivery, select the link in the Last delivery column of the webhook row.
To view the results and payloads of earlier deliveries, select the three-dot menu at the far right of the webhook row.
Securing webhooks
After you’ve configured your server to receive payloads, you want to be sure that the payloads you receive are initiated by SonarQube Cloud and not by attackers. You can do this by validating a hash signature that ensures that requests originate from SonarQube Cloud.
Set your secret
Retrieve your project. See Retrieving projects for more information.
Go to Administration > Webhooks.
You can either select Create to create a new webhook or click an existing webhook’s settings drop-down and select Update.
Enter a random string in the Secret text box. This is used as the key to generate the HMAC hex digest value in the
X-Sonar-Webhook-HMAC-SHA256header.Select Update.
Validate the received payload
After setting your secret, it’s used by SonarQube Cloud to create a hash signature with each payload that’s passed using the X-Sonar-Webhook-HMAC-SHA256 HTTP header. The header value needs to match the signature you are expecting to receive. SonarQube Cloud uses a HMAC lower-case SHA256 digest to compute the signature of the request body. Below is some sample Java code for your server. In this example, we are using the lib from apache commons-codec HmacUtils class.
If the signatures do not match, then the payload should be ignored.
Adding parameters to the webhook payload
If you provide additional properties to your SonarScanner using the pattern sonar.analysis.*, these properties will be automatically added to the section "properties" of the payload.
For example these additional parameters:
would add this to the payload:
Related pages
Webhooks (solution overview)
Last updated
Was this helpful?

