It's all about the answers!

Ask a question

BuildForge .date dot command


Ralph Roach (23145) | asked Feb 13 '13, 2:35 p.m.
It has been a frustrating day trying to figure out how to assign the .date &y&m to my RUN_YYMM variable.

The example in BuildForge's Help is of no use.

I tried to use this:
RUN_YYMM=.date %y%m

It failed with "command not found".   WTF??? 

Can anyone who has SUCCESSFULLY coded a command to retrieve the .date info tell me how it's done?

Or has anyone SUCCESSFULLY coded a command to retrieve the UNIX's date via  "date +%y%m"  in BuildForge?

I do not want to play guessing games (i.e. "try this, try that") cuz I have no time  to guess.

Or is there any other way to possible parse or extract the YYMM portion of BF_D that has a defined format of ymd  (yymmdd) at the start of the job run?

Any help would be greatly appreciated.

Thanks!

--Ralph




3 answers



permanent link
Jim Williams (112) | answered Feb 14 '13, 4:29 a.m.
edited Feb 14 '13, 4:38 a.m.
Ralph,
I had problems getting date to work in a step so I eventually went with a project environment that has a standard variable with a name of ORIGDATESTAMP and value of .date %Y%m%d-%H%M
Then in my first step I have
.bset env "jobname=`echo $ORIGDATESTAMP`"
echo jobname set to ${jobname}

After implementing this I came across another problem with variables in steps that I solved by setting the step environment variable _NO_PREPARSE_COMMAND . This may also have allowed the date command to work as I originally coded it but I never tested it.

Jim....

edit: removed a couple of '.'s I was originally trying to use the unix date command like you.

permanent link
Ralph Roach (23145) | answered Feb 14 '13, 9:52 a.m.
Jim,

Thanks for replying.   However, your response doesn't quite seems to answer my question which is to extract YYMM date portion from current date.

However, my coworker who is strong UNIX person had came up with a solution after several attempts.

.bset env "RUN_YYMM=`date \\+\\%y\\%m`"      (this is back tick, not single quote)
echo $RUN_YYMM

The \\ prevents the % from disappearing.

Have a good day.

--Ralph

Comments
Jim Williams commented Feb 14 '13, 11:26 a.m.

If you only wanted YYMM then ".date %Y%m" would have been enough, for my use I needed a date/time stamp down to minute resolution.

I'm glad you got the other way working, I'm sure I tried \ and \ in front of the % but didn't try in front of the +, so I was nearly there
That's where my suggestion of a step variable _NO_PREPARSE_COMMAND may have worked too, because I think the pre-parser is what strips the % out


Jim....  


permanent link
Spencer Murata (2.3k115971) | answered Feb 14 '13, 11:49 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
 To get the date data without using the *nix date command:
100	2/14/13 10:40 AM		SET	curDate=1302 [.date %y%m]
	
The command is reevaluated everytime the environment is referenced, so it could happen for every step if the step has the .date command specified in the environment.  That is why we usually wrap the environment variable in a .bset with the backticks.  The backticks will run the command echo $curDate on the server which should get us the value "1302" which will then be set as the specified variable from the .bset command.  However the command you have using date, effectively does the same thing, assuming that the date of the agent machine is in the same time zone as the Build Forge server.
	
~Spencer
	

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.