在 sonarqube 中完成每次扫描后,我希望在我的 Discord 应用程序上收到通知。我尝试在 sonarqube webhook 选项中配置我的不和谐 webhook URL,但在扫描代码并且不发送通知后收到 400 错误代码。
我尝试的步骤:
- 从我的不和谐 channel 创建了 webhook URL。
- 在
sonarqube > Administration > Configuration > Webhooks
中配置该 Webhook URL。 - 运行代码扫描,以便向配置的 Webhook 发送通知。
但我遇到了以下错误。
错误
:
Last delivery of Spidey Bot
Response: 400
Duration: 186ms
Payload: .....
最佳答案
事实证明,SonarQube 发送到 Discord 的请求正文格式 Not Acceptable 。它会导致错误的请求。以下是来自 Discord 的记录响应,
{ "message": "Cannot send an empty message", "code": 50006 }
要成功发布消息,必须采用记录的特定格式 https://discordapp.com/developers/docs/resources/webhook#execute-webhook
这个问题的解决方案可能是一个中介 URL,它解析请求正文并使用异常的正文参数命中 Discord Webhook。
关于SonarQube 不会向 Discord webhook 发送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56471110/