Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I set an environment variable with the SVN revision number of a project?

I am trying to get the revision number of a project and save it into a variable. I know I can get the revision number by svnversion command but I'm not sure how I can store it. I am using regular windows command prompt. Basically I'm trying to do something like : set svnVersion= %svnversion% but I'm not sure how??

like image 592
user62958 Avatar asked Dec 10 '22 21:12

user62958


2 Answers

To set the output of variable to the output of svnversion in a batch file, you have to do this:

for /f "delims=" %%a in ('svnversion') do @set myvar=%%a

echo %myvar% 

Different approach: If you have TortoiseSVN you can also use SubWCRev.exe. See get the project revision number into my project? or Automatic SVN Revision Numbering in ASP.Net MVC

like image 85
f3lix Avatar answered Dec 12 '22 09:12

f3lix


If you need this from a remote repository (as in not checked out localy) you can do this

for /f "delims=: tokens=1,2" %%a in ('svn info %SVN_REPO_URL%') do (
  if "%%a"=="Revision" (
    set /a RELEASE_REVISION=%%b
  )
)

I use this in my release process to grab the revision number from a tag.

like image 24
StocksR Avatar answered Dec 12 '22 11:12

StocksR