Variables tasks in Bamboo allow you to:
- pass a value between stages.
- pass a value from a plan to a deployment project.
- read variables from a file using a 'key=value' format.
- print to file the current values of the available variables in your build.
Inject Bamboo variables task
The Inject Bamboo variables task allows you to read the values for variables from a file, and create those variables in your build plan.
The file should use a 'key=value' format. Note that starting from Bamboo version 5.14, you must provide relative paths to the property file.
You can choose if those variables should have a local scope (in which case they cease to exist when the job finishes) or result scope (in which case they are persisted and passed into subsequent stages or related deployment releases).
See Configuring tasks for help in creating a task.
A note regarding using Injected variables with release names: while they can be used for versioning they cannot currently be configured to auto-increment.
Dump variables to log task
The Dump variables to log task simply writes out the current values of all variables used in the build.
See Configuring tasks for help on creating a task.
Q. What happens if the same key is used twice?
A. The last assignment will prevail. If you set the scope to local variable with the same key as an existing result variable, the value of the result variable will be restored when the job finishes.
Q. What if I manually set a variable with the same key as a result variable?
A. Same as above – the last assignment wins.
Q. Can I manually override a result variable in a subsequent manual stage?
Q. What if two jobs in the same stage create the same variable?
A. The variable will exist but it is undefined which value will ultimately be assigned to it.
Q. Is restarting builds, re-running failed jobs or continuing from a manual stage supported?
A. Of course! One caveat though: if you restart a build which has an associated deployment release, the variable in the release will not be refreshed. We're working on that...