Project Webhook not working for Microsoft Teams

Hi I am trying to get a notification to appear in a Microsoft Teams channel. I have configured the webhook in that MS Teams channel and added it in our SonarQube project via the Project>Administration>General>Webhooks page.

I was expecting something to appear in that Teams channel after the project has been analyzed, but nothing ever appears.

I can however use that very same webhook URL to POST directly from Postman and that works OK.

I guess I have missed some configuration, but I am not seeing anything obvious. Hoping someone can offer some guidance :slight_smile:

We are using sonarQube v6.4.

Hey Andy,

Please note that the current supported versions of SonarQube are our 6.7 LTS and 7.4 Latest (the latter of which has a really cool console dedicated to webhook deliveries, etc.). You will have a hard time finding good support for versions earlier than that and should upgrade at your earliest convenience (or sooner!).

We don’t expose anything in the UI related to webhook deliveries prior to 7.1, but you can go to http://yourinstance.com/sonar/api/webhooks/deliveries to see if maybe you’re getting an auth error, etc.

Colin

1 Like

Hi Colin,

Thank you for the info on the API. I have just run that in postman and can see that each entry in the results has: success:false
httpStatus: 400

Nothing else to note, but I can’t really determine from that what the actually issue is with it. The url of the webhook is definitely valid though…

Also, thanks for informing me of the latest supported versions, especially with regard to the console. That sounds like it could be very useful. Will try and find some reading on that so I can see what it can do for us.

A 400 error usually indicates the payload is not in the format expected by the receiver.

1 Like

Indeed, so I have tried taking the json code from Sonar Webhooks page and sent that using postman and my teams channel webhook. I also see the 400 error there.

When I post to Teams channel via my web application, I use a correctly formatted messageCard (json) and that works OK.

Currently, I am just interogatting the Sonar WebAPI to gather the information I want to send to my Teams channel which is fine, but was just interested to see what SonarQube would POST directly after a project has been analyzed :slight_smile:

1 Like

I am getting same issue like above , I am using Sonarqube version is 7.7.
When i will try it from POSTMAN webhook got trigger the alerts in Teams , But in SonarQube it was not triggering i am getting issue like below

Response: 400

Duration: 297ms

Payload:

{
“serverUrl”: “http://localhost:9000”,
“taskId”: “AWu5A3thC2pgVKslFYEh”,
“status”: “SUCCESS”,
“analysedAt”: “2019-07-03T18:03:14+0000”,
“changedAt”: “2019-07-03T18:03:14+0000”,
“project”: {
“key”: “ABC-Sonar”,
“name”: “ABC-test-Sonar”,
“url”: “http://localhost:9000/dashboard?id=ABC-Sonar”
},
“branch”: {
“name”: “master”,
“type”: “LONG”,
“isMain”: true,
“url”: “http://localhost:9000/dashboard?id=ABC-Sonar”
},
“qualityGate”: {
“name”: “Sonar way ABC”,
“status”: “ERROR”,
“conditions”: [
{
“metric”: “new_reliability_rating”,
“operator”: “GREATER_THAN”,
“value”: “3”,
“status”: “ERROR”,
“errorThreshold”: “1”
},
{
“metric”: “new_security_rating”,
“operator”: “GREATER_THAN”,
“value”: “1”,
“status”: “OK”,
“errorThreshold”: “1”
},
{
“metric”: “new_maintainability_rating”,
“operator”: “GREATER_THAN”,
“value”: “1”,
“status”: “OK”,
“errorThreshold”: “1”
},
{
“metric”: “new_coverage”,
“operator”: “LESS_THAN”,
“value”: “0.0”,
“status”: “ERROR”,
“errorThreshold”: “70”
},
{
“metric”: “new_duplicated_lines_density”,
“operator”: “GREATER_THAN”,
“value”: “8.309971966359631”,
“status”: “ERROR”,
“errorThreshold”: “3”
}
]
},
“properties”: {}
}

Help me out to resolve this issue and if any configuration is missed in SonarQube please help me ASAP.

Any news here?

I never got the webhooks to work using v6.4 and have never got it working on later versions. Now, I can’t guarantee that It is not something I configured wrong in SonarQube, but I know that MS Teams will only accept json in messagecard format (the last time I looked) and only the beta would accept the new AdaptiveCard message format (could be in production use by now).

To this end, I ended up writing a custom integration to interrogate SonarQube and push notifications to Teams which works very well for us.

It’s worth using Postman to test the message card json first as it can be a little Teams can be a little temperamental on what it accepts.

Hope this helps.

Natively, SonarQube sends webhooks in exactly one format, which is the one documented here.

Hopefully more integrations will come! MMF-1623

1 Like

Still I am having same issue , any can you please help me out on this

Your json needs to be in MessageCard format for it to appear in Teams. SonarQube does not support sending in that format from webhooks.

Will sonarcloud support this ?

I was also looking for a MS Teams integration, but I couldn’t find one.

So I developed an Azure Function app that transforms a Sonarqube Webhook JSON request to MS Teams card JSON, and sends it to a MS Teams channel Webhook.

You can find it here:

Perhaps someone may find it useful.

1 Like

Hi @Highbyte,

Welcome to the community and thanks for the contribution to the ecosystem! This is a great way to introduce yourself.

 
:smiley:
Ann

1 Like