tcplugins / tcWebHooks

WebHooks plugin for Teamcity. Supports many build states and payload formats.
https://netwolfuk.wordpress.com/category/teamcity/tcplugins/tcwebhooks/
155 stars 30 forks source link

Edited Discord template does not send notification. #231

Closed BizA-Official closed 8 months ago

BizA-Official commented 8 months ago

I have edited the default Discord success template to this:

{
                "embeds": [
                    {
                        "title" : "Success : ${buildName} build #${buildNumber}",
                        "url" : "${buildStatusUrl}",
                        "color" : 3581519,
                        "author" : {
                            "name" : "TeamCity",
                            "url" : "${rootUrl}",
                            "icon_url" : "https://raw.githubusercontent.com/tcplugins/tcWebHooks/master/docs/icons/teamcity-logo-48x48.png"
                        },
                        "fields": [

                            { "name" : "Status", "value" : "${buildStatus}", "inline": false },
                            { "name" : "Project Name", "value" : "[${projectName}](${rootUrl}/project.html?projectId=${projectExternalId})", "inline": true },
                            { "name" : "Build Name", "value" : "[${buildName}](${rootUrl}/viewType.html?buildTypeId=${buildExternalTypeId})", "inline": true },
                            { "name" : "Commit", "value" : "[${substr(build.vcs.number,0,7,32)}](${buildStatusUrl}&tab=buildChangesDiv)", "inline": true },
                            { "name" : "Comment", "value" : "${comment}", "inline": false },
                            { "name" : "Build Number", "value" : "${buildNumber}", "inline": false }
                        ]
                    }
                ]
            }

However, it only works if I run the build manually. If VCS triggers the build, it does not send the edited notification. After I set the template back to the default one, it works with VCS trigger as well.

The default template which works:

{
                "embeds": [
                    {
                        "title": "Success : ${buildName} build #${buildNumber}",
                        "url": "${buildStatusUrl}",
                        "color": 3581519,
                        "author": {
                            "name": "TeamCity",
                            "url": "${rootUrl}",
                            "icon_url": "https://raw.githubusercontent.com/tcplugins/tcWebHooks/master/docs/icons/teamcity-logo-48x48.png"
                        },
                        "fields": [

                            { "name" : "Status", "value" : "${buildStatus}", "inline": false },
                            { "name" : "Project Name", "value" : "[${projectName}](${rootUrl}/project.html?projectId=${projectExternalId})", "inline": true },
                            { "name" : "Build Name", "value" : "[${buildName}](${rootUrl}/viewType.html?buildTypeId=${buildExternalTypeId})", "inline": true },
                            { "name" : "Branch", "value" : "${branchDisplayName}", "inline": true },
                            { "name" : "Commit", "value" : "[${substr(build.vcs.number,0,7,32)}](${buildStatusUrl}&tab=buildChangesDiv)", "inline": true },
                            { "name" : "Triggered By", "value" : "${triggeredBy}", "inline" : true },
                            { "name" : "Agent", "value" : "${agentName}", "inline" : true }
                        ]
                    }
                ]
            } 
netwolfuk commented 8 months ago

Hi @BizA-Official

I suspect you needed to edit the branch and non-branch templates.

Is this an improvement to the discord template that all users would benefit from? Should I look to roll this version into the next tcWebhooks release?

I don't have any webhooks going to discord, so I'm not familiar with it.