How can i change a bamboo variable in a script task

Sylvain Gagne September 16, 2016

Hi,

One of my build task it getting a variable from my pom file, the version number.  This step place the value in variable bamboo_maven_version.

Later, i have another build task, a script one, where i want to change the bamboo_maven_version

In this script :

 

echo "Hello $bamboo_maven_version"

set "bamboo_maven_version=0.0.11"

echo "Hello $bamboo_maven_version"

 

The end result is :

build	16-Sep-2016 12:33:41	Hello 0.0.10-SNAPSHOT
build	16-Sep-2016 12:33:41	Hello 0.0.10-SNAPSHOT

 

Is it possible to change, from a script task, a bamboo variable ?

 

1 answer

4 votes
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 16, 2016

There is no way to change build variable. If you need to propagate some variable to other tasks in same job, you can export it into file, then use Inject variable task, then use this variable in next tasks - https://confluence.atlassian.com/display/BAMBOO/Configuring+a+variables+task

Miroslav Georgiev September 16, 2016

is there a plan to implement that feature?

Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 16, 2016

I don't thinks so, looks like Inject variable task covers all flows

Like Simone Chiaretta likes this
lance_lyons
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 15, 2019

There is a flow that is not covered.  If I want to produce some docker image name that was produced in a build like  servicename:1.0.0.1 and then use this image name in down stream deploys, I am not able to set this variable (eg, latestimagename) so I can use that value in a later deploy.

I could write the value to a file and then on subsequent deploys pull that file as artifact and then read that value but this is a long way from just being able to set a variable.

Has this changed in recent versions of bamboo?

Culme December 12, 2019

Not being able to change the value of a variable does, well... suck. In effect, they aren't variables, but constants.

I can see why this isn't easy to implement in e.g. bash scripts etc, but there could at least be a specific task type "Change bamboo variable value", where some value could be directed into a variable.

The option to use a file "works" in certain scenarios, but so does booting from floppy.

My use case is pretty much exactly as @lance_lyons  above; I need to alter some stuff on a docker image before pushing it to repo.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events