Labelling a build from a deployment plan

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

When you run a deployment plan, you may wish to label the build that produced its artifacts. When the deployment plan runs, you would like the label to be applied automatically.

Solution

This can be achieved using the Bamboo REST API, which specifies an endpoint for retrieving, adding and deleting labels. To do this:

  • Add a Script task to your deployment plan containing the following:

    1 2 3 4 5 6 7 8 9 10 ##### Set these values LABEL="deployed" BAMBOO_URL="http://your.bamboo.inst" USERNAME="youruser" PASSWORD="your password" ##### Leave these values as is XMLDATA='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><label name="'$LABEL'"/>' POSTURL="${BAMBOO_URL%/}"'/rest/api/latest/result/${bamboo.buildResultKey}/label?os_authType=basic' curl -X POST --user $USERNAME:$PASSWORD -H "Content-Type: application/xml" --data "$XMLDATA" -X POST $POSTURL
  • Set the LABEL variable to the label text you would like to apply, and set the BAMBOO_URL, USERNAME and PASSWORD variables accordingly

This will perform an HTTP POST will add your label to the build that produced the artifacts for your deployment

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.