Octopus Deploy

note: This guide is now considered legacy and use of the new API is recommended. A high level guide to migrate to the new API can be found here.

Generate an External Auth Token for your build server to use from your Raygun User Settings page

Follow the instructions for setting up scripts to run directly on the Octopus Server. The rest of these instructions assume you chose to call your server role octopus-server.

In Octopus, create a new "Run a PowerShell script" step in your deployment's Process. Give it a name, and choose the octopus-server role. This ensures your deployment is only registered once, instead of once per server your deployment runs on. Use the following powershell script in this step:

Write-Host "Adding deployment in Raygun"

$githubSha = ""
if ((Test-Path variable:\GithubToken) -And (Test-Path variable:\GithubRepo)) {
    try {
        $repo = "https://api.github.com/repos/" + $GithubRepo
        $tagName = "build-" + $OctopusParameters["Octopus.Action[DEPLOYMENT_STEP_NAME].Package.NuGetPackageVersion"]
        $githuburl = "$repo/git/refs/tags/"+ $tagName + "?access_token=" + $GithubToken
        $tagOutput = Invoke-RestMethod -Uri $githuburl
        $githubCommitUrl = $tagOutput.object.url + "?access_token=" + $GithubToken
        $output = Invoke-RestMethod -Uri $githubCommitUrl
        $githubSha = $output.object.sha
   catch {
        Write-Host "Couldn't find Git tag"

$deploymentId = $OctopusParameters['Octopus.Release.Number']
$ownerName = $OctopusParameters['Octopus.Deployment.CreatedBy.DisplayName']
$emailAddress = $OctopusParameters['Octopus.Deployment.CreatedBy.EmailAddress']
$comment = $OctopusParameters['Octopus.Release.Notes'];

$command = ConvertTo-Json @{
    apiKey = $RaygunApiKey
    version = $deploymentId
    ownerName = $ownerName
    emailAddress = $emailAddress
    comment = $comment
    scmIdentifier = $githubSha

$url = "https://app.raygun.com/deployments?authToken=" + $RaygunAuthToken
try {
    Invoke-RestMethod -Uri $url -Body $command -Method Post -ContentType "application/json"
    Write-Host "Added deployment in Raygun"
} catch {
    Write-Host "Error received when adding deployment in Raygun: " $_

You need to replace DEPLOYMENT_STEP_NAME with the name of the step in your process which deploys your Nuget package. If you don't use Github, you could just remove that whole section, or replace it with your own code to get your Git commit hash.

Add the following Variables to your deployment: RaygunApiKey, RaygunAuthToken, GithubToken, and GithubRepo.

RaygunApiKey should be set your Raygun Application's ApiKey (the same one you use to set Raygun up within your app).

RaygunAuthToken should be set to the External Auth Token you generated in Step 1. You may want to set different RaygunApiKey values depending on the Environment being deployed to if you have separate Raygun Apps for your different Environments.

GithubToken should be set to a Personal Access Token from Github (generated here: https://github.com/settings/applications). The token just needs the repo scope.

GithubRepo should be the full name of your repo - somethink like MindscapeHQ/Raygun4Net.

Deploy your application and watch the Deployments roll in!