Defining a Webhooks with the sonar-scanner-cli

From my Jenkins pipeline I trigger a sonar scan with the CLI tool. I would like to get the quality gate status back, but when I use waitForQualityGate I end up in a timeout although the analysis is complete. I would like to configure the webhook on the CLI with sonar.webhooks.project. Is this possible?

  • which versions are you using
    SonarQube 6.7.5
    Scanner: 3.3.0

  • what are you trying to achieve
    Use the sonar-scanner on a Jenkins and get back the quality gate status.

  • what have you tried so far to achieve this
    Executed the sonar-scanner-cli with an option “-Dsonar.webhooks.project=’${env.JENKINS_URL}sonarqube-webhook/’”.


I totally get why you would think command line definition would work. But it won’t. :smile:

Parameters defined on the analysis command line are valid/live during that analysis. Not before. Not after. They’re not stored in the database, and they don’t update your project settings. They simply temporarily override the values that would otherwise be used, if any.

Webhooks are fired asynchronously, after analysis. Any parameter overrides defined on the analysis command line have poofed away by the time webhooks are called.

So you’re going to need to permanently define your webhook address in the project configuration.


Hi Ann,

Ok, understood. Though I think it should be possible to add Webhooks to the project with a login provided. Generally, I create new projects via triggering the scan. So it would be nice, if Webhooks are considered during project creation.

Is there another way to create project specific Webhooks programmatically?


Take a look at the api/webhooks services. You’ll find a link to the on-board documentation of your version’s web services in the page footer.


To complement Ann’s answer – the api/webhooks domain can be used to set webhooks on projects in SonarQube 7.1+, for SonarQube 6.7 POST api/settings/set will need to be used instead.

Also, if you need to set one webhook on every project, consider setting a webhook at the Global level.

1 Like