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

This widget could not be displayed.

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.

This widget could not be displayed.

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)

This widget could not be displayed.

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 Sign up to answer
Community showcase
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

67 views 0 1
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