Bamboo added the ability to define conditional tasks in Bamboo 7.1. Bamboo provides the ability to condition the task on a variable as a built in capability and enable 3rd parties to contribute additional condition types. No matter what condition you want to do, it is supported by the CLI for Plan Creation Scripting by using the appropriate field values. The variable example below is provided and other condition types can be handled similarly - the user will need to figure out the equivalent fields for those unique capabilities (suggest you add a task manually and then run exportJob to see what is needed in a plan creation script.
Example - Variable Condition Type
|Field||Example Value||Description||Other Values|
|conditionTask||true||Make task conditional with true value.||false|
|com.atlassian.bamboo.plugins.bamboo-conditional-tasks:variableCondition||Type of condition. This is the built-it variable condition available in Bamboo.||Depends on 3rd party or custom apps installed|
|exitCode||Name of the Bamboo variable that will be used to condition the task.|
|not_equals||Operation used to determine condition based on variable value and compare value||equals, matches (means regex)|
|task.condition.variable.value.not_equals||0||Compare value for a not_equals condition check|
|task.condition.variable.value.equals||N/A when using not_equals||Compare value for a equals condition check|
|N/A when using not_equals||Match regex for a match condition check|
-a addTask --plan CLI-EXAMPLES --job JOB1 --taskKey SCRIPT --field "scriptBody=..." \
--field conditionalTask=true \
--field selectedCondition=com.atlassian.bamboo.plugins.bamboo-conditional-tasks:variableCondition \
--field task.condition.variable.name=exitCode \
--field task.condition.variable.operation=not_equals \
--field task.condition.variable.value.not_equals=0 \
Dynamically setting variables
Since task conditioning is based on Bamboo variables, is there a quick way to set a Bamboo variable so it can later be used in conditioning?
The inject Bamboo variables task (see Configuring variables task) will dynamically set job or plan level values for Bamboo variables. This is done through a properties file which can be dynamically created in another task.