Use of Jenkins environment variable in directory path

777 views
Skip to first unread message

TP

unread,
Aug 29, 2013, 8:44:52 AM8/29/13
to jenkins...@googlegroups.com

I'm relatively new to the Jenkins world and I'm having issues with the use of environment variables.

I'm currently running builds from code I check out from a git repository. I inject an environment variable called GIT_BUILD_NUMBER that I pull from the checkout and use it successfully in a Windows Batch Command Block:

::Build Project
python buildProj.py --branch %Branch% --bin_src %WORKSPACE% --build_number %GIT_BUILD_NUMBER%

This executes successfully with the proper git build number. In the very next "Execute Windows Batch command" block, I simply try to use that same variable in a directory path and this causes the build to fail:

J:\builds\%GIT_BUILD_NUMBER%\

I've also tried this:

J:\\builds\\%GIT_BUILD_NUMBER%\\

When I echo this line, I just get:

J:\builds\\

Any insight would be greatly appreciated.

mark_k...@symantec.com

unread,
Aug 29, 2013, 2:40:56 PM8/29/13
to jenkins...@googlegroups.com
Have you tried to use ${GIT_BUILD_NUMBER} instead of %GIT_BUILD_NUMBER%?

If you do a SET command in the second Batch command block do you see the GIT_BUILD_NUMBER set?

Is it possible to run the commands you need to in the first block where GIT_BUILD_NUMBER appears to be working fine?

Thanks
Mark
Reply all
Reply to author
Forward
0 new messages