Integrating Sonarcloud with Microsoft Teams

sonarcloud
webhooks

(AndrewB) #1

Hi,

I’ve set up a webhook from Sonarcloud to Microsoft Teams, but it appears to error (though I’m unable to see any logs or reasons why):

image

I’ve checked from various other services that the webhook is valid and has no authentication required (though it does use HTTPS).

Has anyone used this before or had success with it?

Thanks.


(Fabrice Bellingard) #2

Hi Andrew, I’m not familiar with Microsoft Teams: can you describe what it is and what you are trying to achieve with webhooks?


(AndrewB) #3

Hi, thanks for getting back.

Microsoft Teams is Microsoft’s new chat app (like slack) and replacement for Skype for Business. It’s now bundled with 365 so there’s a large push on it.

I’m trying to use the webhook for notifications from Sonarcloud to Teams. Team’s is fairly easy to setup an incoming webhook, which I’ve done, and put the URL into sonarcloud, however nothing seems to be received (not sure its even sent).

I’ve confirmed the webhook is valid using other external third parties (atlassian etc).


(Fabrice Bellingard) #4

Thanks @andrew1 for the explanation! :slight_smile:

What do you see when you go to your project’s “Administration > Webhooks” page and you click on the details to see the recent deliveries:

image


(AndrewB) #5

I get a response 400.

image

Can the json be formatted at all before its sent, or is there any customisation at all? I’m not aware of anyone using the functionality, so unsure where these webhooks from sonarcloud are successfully deployed.


(Fabrice Bellingard) #6

Just to clarify @andrew1: what endpoint do you configure in SonarCloud? The payload of the webhook cannot be changed, it’s up to the endpoint to make sure that it will understand the payload to be able to deal with it.


(AndrewB) #7

Hi, the endpoint is the Teams Channel that we use. For the end customer its a bit of a rock and a hard place, slack/teams support webhooks but it looks as though you’re can’t be altered at all, or have a header or footer attached. Is this something that could be added?

I’ve included an example json that could be sent and received from below

{
    "@type": "`MessageCard`",
    "@context": "http://schema.org/extensions",
    "themeColor": "0076D7",
    "summary": "Larry Bryant created a new task",
    "sections": [{
        "activityTitle": "![TestImage](https://47a92947.ngrok.io/Content/Images/default.png)Larry Bryant created a new task",
        "activitySubtitle": "On Project Tango",
        "activityImage": "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
        "facts": [{
            "name": "Assigned to",
            "value": "Unassigned"
        }, {
            "name": "Due date",
            "value": "Mon May 01 2017 17:07:18 GMT-0700 (Pacific Daylight Time)"
        }, {
            "name": "Status",
            "value": "Not started"
        }],
        "markdown": true
    }],
    "potentialAction": [{
        "@type": "ActionCard",
        "name": "Add a comment",
        "inputs": [{
            "@type": "TextInput",
            "id": "comment",
            "isMultiline": false,
            "title": "Add a comment here for this task"
        }],
        "actions": [{
            "@type": "HttpPOST",
            "name": "Add comment",
            "target": "http://..."
        }]
    }, {
        "@type": "ActionCard",
        "name": "Set due date",
        "inputs": [{
            "@type": "DateInput",
            "id": "dueDate",
            "title": "Enter a due date for this task"
        }],
        "actions": [{
            "@type": "HttpPOST",
            "name": "Save",
            "target": "http://..."
        }]
    }, {
        "@type": "ActionCard",
        "name": "Change status",
        "inputs": [{
            "@type": "MultichoiceInput",
            "id": "list",
            "title": "Select a status",
            "isMultiSelect": "false",
            "choices": [{
                "display": "In Progress",
                "value": "1"
            }, {
                "display": "Active",
                "value": "2"
            }, {
                "display": "Closed",
                "value": "3"
            }]
        }],
        "actions": [{
            "@type": "HttpPOST",
            "name": "Save",
            "target": "http://..."
        }]
    }]
}

(Fabrice Bellingard) #8

What you are looking for is a Microsoft Teams integration feature, which we don’t have. SonarCloud “just” has a webhook notification feature - like what GitHub has for instance.


(AndrewB) #9

And I’m guessing the ability to customise webhooks isn’t planned?

Is there an ability to send notifications to a custom email address (not the email address associated with the account) as this could assist in the issue?


(Fabrice Bellingard) #10

No it’s not.

No - however you could create a “bot” account with the desired email address, sign up with it and add it to your org so that it gets the notifications.