How to have dynamic variable in bamboo

Hi,

I'm trying to configure bamboo to have nightly builds. My goal is that after the build, the created artifacts are copied to another folder where all my nightly builds are stored.

The structure I am aiming for is the following:

C:/Sync/.../20140622-Project xx/<all my artifacts>

Everything is in place. I have a variable containing the date, I use the 'Artifact download' task in a Deploy part, and in the path, I put my date variable which is correctly substituted.

Except for one thing, I don't find a way to update the value of my variable. I tried via a script called at the begining of my Deploy to change it (global plan variable) "set bamboo_releaseDate=20140622" but this doesn't work.

I tried to change an environment variable, and access it in bamboo in the Artifact download ${system.bamboo_releaseDate}. It gets the system variable, but if I update it, it doesn't take the change into account. The new value is only taken if I restart the service of my bamboo.

So I have more a configuration/best practice question. What should be the way to have dynamic variable ? What do you suggest ? Can I use the task mentionned above, or should I change completely ?

Thanks for your help !

Christophe

2 answers

1 accepted

This widget could not be displayed.

I used the solution of Shari, and it works effectively.

Thanks for your help !

Christophe

This widget could not be displayed.

You should be able to run these commands in a step -

set TODAY=%year%%month%%day%
@echoTODAYVAR=%TODAY%>"${bamboo.pathroot}\Bamboo\xml-data\build-dir\TODAYVAR.properties"

Then run a step "Inject Bamboo Variables from file", where you reference the variable stored in the first step -

../TODAYVAR.properties

Then in a 3rd step set TODAY by doing the following -

for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set year=%%c
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set month=%%a
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set day=%%b
set TODAY=%year%%month%%day%
@echoTODAYVAR=%TODAY%>"${bamboo.pathroot}\Bamboo\xml-data\build-dir\TODAYVAR.properties"

Then you can reference TODAY variable (say in your copy step) with the following -

%TODAY%_${bamboo.current.version}-${bamboo.buildNumber}

which would append the version of the app and the build number to the YYYYMMDD, i.e. 20140623_1.5.8_21

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

147 views 16 7
Join discussion

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