Use case
A task may define some *custom build variable* that would need to later be retrieved in subsequent tasks.
The current mechanism to handle this is to share artifacts between the tasks - the problem with this approach is that the "native" bamboo tasks, such as the ant task could not access this "custom build variables"; we would need to write a wrapper script that parses the artifact then invoked the ant command. Furthermore, using artifacts requires to add extra logic in every task to read/write to the artifact.
Is it possible to set a bamboo build variable ( attach it to the plan, see code below) and access it in later stages - without going through artifacts?
Tested case
I created custom build variables using the variableDefinitionManager
VariableDefinition vd = new VariableDefinitionImpl();
vd.setPlan(plan);
vd.setVariableType(VariableType.PLAN);
vd.setKey(k);
vd.setValue(v);
variableDefinitions.add( vd );
variableDefinitionManager.saveVariableDefinitions(variableDefinitions);
What currently works:
* Pass variables between tasks
Plan
Stage 1
Job1
task 1A: set_plan_variable myVar
task 1B : print_variable myVar
What does not work:
* Pass variables between a jobs (expected not to work since jobs can be concurrent)
* Pass variables between a stages
Plan
Stage 1
Job1
task 1A: set_plan_variable myVar
Stage 2:
Job1
task 2A : print_variable myVar
Note
I opened https://jira.atlassian.com/browse/BAM-10899 to request the feature, but if someone has a magic trick to share, please do !