Nested Variables
Nested Variables is an extension of the existing Global and Plan variables. It allows system and plan administrators to re-use existing variables. The goal is to make variable maintenance easier and allow Bamboo users to get the most out of their existing variables. In addition, it supports enforcing security where access to global variables is limited to system administrators without adding extra constraints to plan administrators to create their own variables.
Nested variables also allow you to create variables with more than 255 characters, which is the default limit of variables in Atlassian Bamboo. By chaining multiple variables using Nested Variables you can create a workaround for this limit.
Creating a nested variable
This example assumes you already have Bamboo setup with the Utility Belt app and have created a Plan.
You can create a nested variable in three simple steps:
Create a Global or Plan variable. Use helloVariable as key and Hello as value.
Create another Global or Plan variable. Use helloWorldVariable as key and ${bamboo.helloVariable} world! as value.
Create a Job with a Script task which has the following inline script body:
echo "${bamboo.helloWorldVariable}"
Run the plan and look at the log files. You will see an echo output of Hello world!.
Limits to the use of Nested Variables
Although there is no limit to the number of nested variables or the depth level of the nesting of variables, there are still some limitions that you might want to consider:
Nested variables are only substituted during task execution. For instance, you cannot use nested variables in the repository url field, even though you can use regular variables for this.
The variable limit of 255 character still applies to the variables fields. In order to create a workaround, you will need to split up the values in multiple nested variables. Each of those variables should stay within the variable value limit.
Bamboo does not support variable modifications by add-ons in deployment plans. Due to this limitation, the Nested Variables functionality can only be used in build plans.