Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Table of Contents

Webhooks POST to the external HTTP(S) URLs you specify after the analysis report has been processed by the Compute Engine. Typically, webhooks would be used to notify external tools of the Quality Gate statuses of your projects.

The HTTP(S) call:

  • is made regardless of the status of the Background Task
  • includes a JSON document as payload, using the POST method
  • has a content type of "application/json", with UTF-8 encoding

Configuration

You can configure up to 10 webhooks in Administration > Configuration > General Settings > Webhooks.

An additional set of 10 webhooks can be configured at the global level.

If configured, all 20 will be executed.

Payload Format

The Payload is a JSON document. Here what you can find in this JSON document:

  • when the analysis was performed: see "analysedAt"
  • the identification of the project analyzed: see "project"
  • each Quality Gate criterion checked and its status: see "qualityGate" 
  • the Quality Gate status of the project: see "qualityGate.status"
  • the status and the identifier of the Background Task : see "status" and "taskId"
  • user-specified properties: see "properties"

Example

{
    "analysedAt": "2016-11-18T10:46:28+0100",
    "project": {
        "key": "org.sonarqube:example",
        "name": "Example"
    },
    "properties": {
    },
    "qualityGate": {
        "conditions": [
            {
                "errorThreshold": "1",
                "metric": "new_security_rating",
                "onLeakPeriod": true,
                "operator": "GREATER_THAN",
                "status": "OK",
                "value": "1"
            },
            {
                "errorThreshold": "1",
                "metric": "new_reliability_rating",
                "onLeakPeriod": true,
                "operator": "GREATER_THAN",
                "status": "OK",
                "value": "1"
            },
            {
                "errorThreshold": "1",
                "metric": "new_maintainability_rating",
                "onLeakPeriod": true,
                "operator": "GREATER_THAN",
                "status": "OK",
                "value": "1"
            },
            {
                "errorThreshold": "80",
                "metric": "new_coverage",
                "onLeakPeriod": true,
                "operator": "LESS_THAN",
                "status": "NO_VALUE"
            }
        ],
        "name": "SonarQube way",
        "status": "OK"
    },
    "status": "SUCCESS",
    "taskId": "AVh21JS2JepAEhwQ-b3u"
}

How can I provide additional parameters to webhooks?

If you provide additional properties to your SonarQube Scanner using the pattern sonar.analysis.*, these properties will be automatically added to the section "properties" of the payload.

Example:

sonar-scanner -Dsonar.analysis.scmRevision=628f5175ada0d685fd7164baa7c6382c1f25cab4 -Dsonar.analysis.buildNumber=12345

Payload will contain:

"properties": {
  "sonar.analysis.scmRevision": "628f5175ada0d685fd7164baa7c6382c1f25cab4",
  "sonar.analysis.buildNumber": "12345"
}

Deliveries

There is currently no UI to track webhook deliveries; only Web Services are available to follow them, and those services are in Beta and are subject to change without notice. Response records are purged after 30 days.

  • api/webhooks/deliveries
  • api/webhooks/delivery

There is no Web API to register/unregister a Webhook. You may only use the UI to perform this action.

This is not possible to provide credentials to the Webhook.

Noteworthy

  • the URL must respond within 10 seconds or the delivery is marked as failed 
  • the HTTP header "X-SonarQube-Project" is fed with the project key to quickly identify the project involved


  • No labels