Deployments to Raygun from Powershell

Registering Deployments from a Powershell v4 Script

Step 1

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

Step 2

Add this script somewhere your deployment process can use it:

    [string] $raygunAuthToken,
    [string] $raygunApiKey,
    [string] $version,
    [string] $ownerName,
    [string] $emailAddress,
    [string] $scmIdentifier,
    [string] $releaseNotes

Write-Debug "Adding deployment in Raygun"
$url = "https://app.raygun.io/deployments?authToken=" + $raygunAuthToken

$command = ConvertTo-Json @{ 
    apiKey = $raygunApiKey
    version = $version
    ownerName = $ownerName
    emailAddress = $emailAddress
    comment = $releaseNotes
	scmIdentifier = $scmIdentifier

$bytes = [System.Text.Encoding]::ASCII.GetBytes($command)
$web = [System.Net.WebRequest]::Create($url)
$web.Method = "POST"
$web.ContentLength = $bytes.Length
$web.ContentType = "application/json"
$stream = $web.GetRequestStream()

$response = [System.Net.HttpWebResponse]$web.GetResponse()
if($response.StatusCode -eq [System.Net.HttpStatusCode]::OK) {
    Write-Debug "Added deployment in Raygun"
} else {
    Write-Host "Error received when adding deployment in Raygun: " $response.StatusCode " - " $response.StatusDescription

Step 3

Call the deployment script after your release process is finished.

-raygunAuthToken   Your External Auth Token
-raygunApiKey      Your Application's API Key
-version           The version of your application that you've just deployed
-ownerName         The name of the user who created this deployment
-scmIdentifier     The identifier of the commit that this release was built from.
-emailAddress      The email address of the user who created this deployment 
                   (should be a raygun user)
-releaseNotes      The release notes for this deployment. Will be formatted as Markdown.

Documentation missing?

If we don't have documentation about your desired topic, send us a message and we'll create it for you.