unable to employ variables created in batch script Bamboo task

For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set thedate=%%c_%%a_%%b)
echo %thedate%
mkdir C:\Users\avalencia\test2\${system.thedate}_${bamboo.custom.svn.revision.number}
xcopy.exe TechServiceTool\TechServiceTool\bin\Release C:\Users\avalencia\test2\${system.thedate}_${bamboo.custom.svn.revision.number}\ /e

per build log, date evaluates correctly in the first line (set thedate=%%c_%%a_%%b), but is not usable in the lines afterward. how can I use thedate batch variable after it is correctly set in the first line. the goal is to have the date in a specific format to use to create a directory in which to put the build. i'd rather not create an msbuild or ant file just for this.

3 answers

Have you tried just %thedate% ? Bamboo system variables are only updated at task boundaries, and not within a task.

Do you need the value in future tasks>?

yes i have tried %thedate%, and nothing gets substituted. essentially, it seems that the set command does not get executed. or, if it does, the variable is seemingly useless thereafter. i do not need the value in future tasks.

if you pull this code into a .bat file and run manually does it give the result you expect (other then svn which will be missing).

yes. i see where we're going with this. i believe the svn var evaluates w/in the task prior to functional parameterization. if not, then that will be the next barrier. i really didn't want to have to check any build-specific files into SVN which accomplish such trivial tasks. the script task, executable as a batch file should not be advertised as such if not the case.

xcopy, as it turns out, creates all intermediary directories, making the mkdir statement unneccessary. the echo statement was there just as a test. only one statement uses the variable. so, i simply made that last statement my do body rendering the batch variable useless. until somebody can figure out how to set batch variables in a script batch task, the solution to this problem is.

For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (xcopy.exe TechServiceTool\TechServiceTool\bin\Release C:\Users\avalencia\test2\%%c_%%a_%%b_${bamboo.custom.svn.revision.number}\ /e)

I never could get system variables to work either. I use the injection plugin as a work around. Clunky but it works. And specifically it was on the date. Seems like a useful idea for an enhancement. have today's date as a bamboo variable since so many of us use dates in folder names (to hold builds for deployment etc.)

Suggest an answer

Log in or Join to answer
Community showcase
Louis De Jaeger
Posted Thursday in Off-topic

Friday fun: your best joke

Hi all Lets make this Friday fun really fun and post one (or more) of your best jokes! The joke can be about an Atlassian product, or just a really fun joke you want to share! I’m not the best j...

189 views 12 3
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot