Labelling a build from a deployment plan
Purpose
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:
##### 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
Last modified on Feb 10, 2016
Powered by Confluence and Scroll Viewport.