Skip to content

Instantly share code, notes, and snippets.

@sorashi
Last active September 28, 2018 20:12
Show Gist options
  • Save sorashi/fb2c22bcaaaeb3f7cf5ab93ec6f01f66 to your computer and use it in GitHub Desktop.
Save sorashi/fb2c22bcaaaeb3f7cf5ab93ec6f01f66 to your computer and use it in GitHub Desktop.
Custom AppVeyor webhook for Discord
{
  "embeds": [
    {
      "title": "Build {{buildId}}",
      "url": "{{buildUrl}}",
      "color": {{#passed}}40973{{/passed}}{{^passed}}11672839{{/passed}},
      "footer": {
        "icon_url": "{{#passed}}https://i.imgur.com/Rf4g8v6.png{{/passed}}{{^passed}}https://i.imgur.com/QaERwAW.png{{/passed}}",
        "text": "{{#passed}}Success{{/passed}}{{^passed}}Failure{{/passed}}"
      },
      "author": {
        "name": "{{commitAuthor}}",
        "url": "https://github.com/{{repositoryName}}/commit/{{commitId}}"
      },
      "fields": [
        {
          "name": "Commit",
          "value": "[{{commitMessage}}](https://github.com/{{repositoryName}}/commit/{{commitId}})"
        },
        {
          "name": "Duration",
          "value": "{{duration}}",
          "inline": true
        },
        {
          "name": "Build version",
          "value": "{{buildVersion}}",
          "inline": true
        }
      ]
    }
  ]
}

Setup your webhook in AppVeyor → Settings → Notifications

Want to know more parameters? AppVeyor provides this JSON object to use with mustache

{
    "passed":true,
    "failed":false,
    "status":"Success",
    "started":"2014-04-14 7:57 PM",
    "finished":"2014-04-14 7:58 PM",
    "duration":"00:01:30.3741236",
    "projectId":12064,
    "projectName":"test-web",
    "buildId":14636,
    "buildNumber":26,
    "buildVersion":"1.0.26",
    "repositoryProvider":"gitHub",
    "repositoryScm":"git",
    "repositoryName":"JohnSmith/test-web",
    "branch":"master",
    "commitId":"ad2366f0c4",
    "commitAuthor":"John Smith",
    "commitAuthorEmail":"[email protected]",
    "commitDate":"2014-04-14 1:54 AM",
    "commitMessage":"Some changes to appveyor.yml",
    "committerName":"John Smith",
    "committerEmail":"[email protected]",
    "isPullRequest":true,
    "pullRequestId":1,
    "buildUrl":"https://ci.appveyor.com/project/JohnSmith/test-web/build/1.0.26",
    "notificationSettingsUrl":"https://ci.appveyor.com/notifications",
    "messages":[],
    "jobs":[
       {
          "id":"es941edratul5jm3",
          "name":"",
          "passed":true,
          "failed":false,
          "status":"Success",
          "started":"2014-04-14 7:57 PM",
          "finished":"2014-04-14 7:58 PM",
          "duration":"00:01:27.9060155",
          "messages":[],
          "compilationMessages":[
             {
                "category":"warning",
                "message":"Found conflicts between different versions of the same dependent assembly....",
                "details":"MSB3247",
                "fileName":"..\\..\\Program%20Files%20(x86)\\MSBuild\\12.0\\bin\\Microsoft.Common.CurrentVersion.targets",
                "line":1635,
                "column":5,
                "projectName":"MyWebApp",
                "projectFileName":"MyWebApp\\MyWebApp.csproj",
                "created":"2014-04-14T19:57:54.0838622+00:00"
             }
          ],
          "artifacts":[
             {
                "fileName":"MyWebApp.zip",
                "name":"MyWebApp",
                "type":"WebDeployPackage",
                "size":3491576,
                "url":"https://ci.appveyor.com/api/buildjobs/es941edratul5jm3/artifacts/token/261761baaaa8337f0a13fa8b5587451ff2d13e4cff095c74e6eabb5d5dea0909/MyWebApp.zip"
             }
          ]
       }
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment