Resetting Variables via a REST API call and Dynamic Release versioning

Still need help?

The Atlassian Community is here for you.

Ask the community

Resetting Variables

Bamboo builds or deployment projects can be triggered externally using Bamboo's REST API (https://docs.atlassian.com/bamboo/REST/5.0-SNAPSHOT/), and variable values can be reset by bamboo.variable.myVariable=valueForMyVariable option as it's described here - https://docs.atlassian.com/bamboo/REST/5.0-SNAPSHOT/#d2e927. For example, if there is a plan variable definition (myVariable=valueOfMyVariable) in the plan that we want to trigger, we can change the value by passing it to the REST call:

curl -X POST --user admin:admin "http://localhost:8085/rest/api/latest/queue/PROJ-PLAN?executeAllStages=true&bamboo.variable.myVariable=newValue"

where the "admin:admin" is the username:Password of a Bamboo user; instead of "localhost", the correct Bamboo hostname should be used; "PROJ-PLAN" is the project and plan keys of the plan that we want to trigger; "variable" - this component is for the REST API call and must be present; "myVariable" is the name of the variable that we want to reset; "newValue" is the new value that we are passing to the plan.

Use case

Release version numbering in Deployment projects can be configured to use the custom variable values. In order to do that the plan can be triggered using the above mentioned curl command, and when the build result is ready, we can make a new Release for the Deployment environment and use the custom variable: release-${bamboo.myVariable}. When a new release is created, the version will look like: "release-newValue".

Last modified on Oct 18, 2017

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.