Atlassian Bamboo

Deployments in Raygun with Atlassian Bamboo

 

Registering Deployments with Atlassian Bamboo

Step 1

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

Step 2 - Linux Hosts

In your Bamboo Deployment project, create a new Script task. Give it a description and use the following inline shell script as the script body:

# Run the script in bash rather than sh
if [ "$(ps -p "$$" -o comm=)" != "bash" ]; then
    bash "$0" "$@"
    exit "$?"
fi

url="https://app.raygun.io/deployments?authToken=${bamboo.raygun.authToken}"

read -d '' deployment <<- EOF
{
    apiKey: \"${bamboo.raygun.apiKey}\",
    version: \"${bamboo.deploy.version}\",
    ownerName: \"${bamboo.ManualBuildTriggerReason.userName}\",
    comment: \"${bamboo.resultsUrl}\"
}
EOF

echo "$deployment"

curl -H "Content-Type: application/json" -d "$deployment" $url

if [ "$?" -ne "0" ]; then
    echo "Could not send deployment details to Raygun"
    exit 1
fi

Step 2 - Windows Hosts

In your Bamboo Deployment project, create a new Script task. Give it a description, then tick the 'Run as Powershell script' option. Use the following inline Powershell script as the script body:

Write-Host "Adding deployment in Raygun"

$ownerName = '${bamboo.jira.username}'
if($ownerName -eq '${bamboo.jira.username}')
{
    ownerName = 'Build Server'
}

$command = ConvertTo-Json @{
    apiKey = '${bamboo.raygun.apiKey}'
    version = '${bamboo.deploy.version}'
    ownerName = $ownerName
    comment =' ${bamboo.resultsUrl}'
    scmIdentifier = '${bamboo.repository.revision.number}'
}

$url = "https://app.raygun.io/deployments?authToken=" + '${bamboo.raygun.authToken}'
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: " $_
}

Step 3

Add the following Variables to your Deployment Configuration: raygun.apiKey, and raygun.authToken.

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

raygun.authToken should be set to the External Auth Token you generated in Step 1.

Step 4

Deploy your application and watch the Deployments roll in!

Documentation missing?

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