Search code examples
sonarqubediscordwebhookssonarqube-scan

SonarQube doesn't send notification to Discord webhook


I want notification on my discord app after completing every scan in sonarqube. I have tried to configured my discord webhook URL in sonarqube webhook option but it getting 400 error code after scanning the code and not sending notification.

Steps i tried :

  1. Created webhook URL from my discord chennel.
  2. Configured that webhook URL in sonarqube > Administration > Configuration > Webhooks.
  3. Run code scan So that it send notification to configured webhook.

But i am getting below error.

Error :

Last delivery of Spidey Bot

Response: 400
Duration: 186ms
Payload: .....

Discord webohook screenshot attached

SonarQube Error screenshot attached


Solution

  • It turns out, request body format which SonarQube sends to Discord is not acceptable. It leads to bad request error. Below is logged response from Discord,

    { "message": "Cannot send an empty message", "code": 50006 }

    To successfully post the message it must be in the specific format documented https://discordapp.com/developers/docs/resources/webhook#execute-webhook

    The solution to this could be a mediatory URL which parses the request body and hits Discord Webhook with excepted body params.