Can I assign a value to a bamboo variable in script?

I want to be able to use a script to parse a file, read out a value and then assign this value to a plan variable. I cannot see a way of assigning the variable however.

I have tried various scripts like:

Write-Output Initial Date: "${bamboo.CURRENT_ASSEMBLY_VERSION}"
set "bamboo_CURRENT_ASSEMBLY_VERSION=$rawVersionNumber"
Write Output Should have set to: $rawVersionNumber
Write-Output Using the shared assembly version number: "${bamboo.CURRENT_ASSEMBLY_VERSION}"

Is this possible with Elastic Bamboo?

4 answers

You can use the injection variable plugin to simulate this. Basically you write out to a text file, then read it in from the injection plugin task once it's there, you can use it as a variable within the same stage. I think you have to reload it in a new stage, which is a nuisance but works fine.

0 vote

Hi Mark,

It is currently impossible to change a variable value from within tasks while the build is running. This is being tracked here:

https://jira.atlassian.com/browse/BAM-10272

I would suggest adding any comments to the issue above as well as voting on the issue to create it's popularity and likelihood of being implemented in a future release.

For more information on how Atlassian implements new features and improvements please see the following document:

http://confluence.atlassian.com/display/DEV/Implementation+of+New+Features+Policy

Kind regards,
Felipe Kraemer
Atlassian Support

Ah, this plugin doesn't seem to be available for the cloud. We are running Elastic Bamboo. I thought that this meant that it is not currently able to be run with our version?

4 years later and we still don't have a "good" solution for managing variables that might come up during the build... why is this not a surprise with Atlassian. 

Inject Variable task is part of Bamboo and it should be used to propagate variables from environment to other tasks, jobs and stages

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,569 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you