Atlassian Bamboo
  • Updated on 28 Jun 2018
  • 3 minutes to read
  • Contributors
  • Print
  • Share
  • Dark

Atlassian Bamboo

  • Print
  • Share
  • Dark

If you are using Atlassian's Bamboo for your CI/CD pipeline, you can easily add Tasks that will notify Retrace's Deployments API during or after your deployments. The Deployments API offers three different actions (Start, Complete, and Cancel) that can be passed as arguments depending on how you are configuring the Task within your existing pipeline. Check out our Deployment Tracking Overview guide to learn how these deployment notifications can be used within Retrace.

Create a Build Task

We will be adding a Task that sends a request to the Deployment Tracking API using a script. From the Job that will be notifying Retrace's Deployment API of a started, completed, or canceled deployment, add a Task and choose the Script type.

PowerShell or Bash
You can use either PowerShell or Bash depending on the OS of your build server and your preferences.

Configure The Script

To see the generic examples for Bash and Powershell reference our API Code Samples guide.

Windows Powershell

Choose 'Windows Powershell' for the Interpreter, and 'Inline' for the script location.

For the Script body, paste the following:


        $apiKey = '${bamboo.Stackify.ApiKey}',
        $version = '${bamboo.deploy.release}',
        $app = '${bamboo.Stackify.AppName}',
        $env = '${bamboo.deploy.environment}', 
        $uri ='${bamboo.resultsUrl}',
        $name = '${bamboo.buildKey}',
        $branch ='${bamboo.planRepository.branch}',
        $commit ='${bamboo.planRepository.revision}',
        $hostApi = ''

# build the post url
if (!$hostApi) { $hostApi= '' }
$post = $hostApi.TrimEnd('/') + '/api/v1/deployments/' + $action

# build the authorization header
$headers = @{'authorization'='ApiKey ' + $apiKey}

# build the body of the post
if (!$name) { $name = $version }
$bodyObj = @{ Version=$version; AppName=$app; EnvironmentName=$env; }
if ($action -eq "start" -or $action -eq "complete"){

        $bodyObj.Name = $name
        if ($uri) { $bodyObj.Uri = $uri }
        if ($branch) { $bodyObj.Branch = $branch }
        if ($commit) { $bodyObj.Commit = $commit }

$body = ConvertTo-Json $bodyObj

# send the request
Invoke-WebRequest -Uri $post -Method POST -ContentType "application/json" -Headers $headers -Body $body

Running the Powershell script from a file

The Powershell script can be imported from the build tools repository and called from the repository directory like so: ${}\build-tools\script\stackify-deploy.ps1

complete -env \\"<EnvironmentName>\\" -app "<AppName>" -apiKey "<ApiKey>" -version "${bamboo.deploy.release}-b${bamboo.buildNumber}" -uri "${bamboo.resultsUrl}" -branch "${bamboo.planRepository.branch}" -commit "${bamboo.planRepository.revision}"


Choose /bin/bash for the Interpreter and Inline for the script location. Paste the following in the Script Body. Please note this will use a "Complete" action when submitting the deployment request. If you would like to use Start or Cancel, simply change the endpoint to or

curl -X POST  
-H 'authorization: ApiKey ${bamboo.Stackify.ApiKey}'  
-H 'content-type: application/json'  
-d '{"Version": "${bamboo.deploy.release}", "AppName": "${bamboo.Stackify.AppName}", "EnvironmentName": "${bamboo.deploy.environment}"}'

Configure Script Variables

For variables that will not change for this Plan, set them in the Plan Variables tab. The script looks for the following two, but this can easily be changed as needed.

For any variables you want to pass in manually, you can remove the '$bamboo.variable' from the script and pass it as an Argument.

For Powershell, this is also where we have passed in the Action argument which may change depending on where in the pipeline you are adding this Task. You must pass in the Action argument, either start, cancel, or complete depending on where you are including this Task. If you specifiy "complete" then a Deployment Request will be created and completed in one call. Any arguments which may contain spaces will need to be enclosed in escaped double quotes (\”)

View Deployments in Bamboo

You should see the results in your logs after running the plan.

If the plan ran successfully you should now be able to check in Retrace for your deployment requests: You can learn more about viewing deployment history.

Once a Deployment Request has been marked as Complete, it may take a bit before the Deployment flags show up throughout the Retrace UI. Completed deployment requests are processed by the client 5 min maintenance job to create the deployment record.

Was this article helpful?