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??
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With