script to automatically increment the version number

595 views
Skip to first unread message

ranjith kumar

unread,
Dec 10, 2013, 5:21:13 AM12/10/13
to jenkin...@googlegroups.com
Hi All,

I am new to Jenkins.

I am using SVN for version control. I am having a visual studio
project(C++ project and .sln project file).
I am storing version information in 'projectname.rc' file. I have
setup Jenkins to build my project everyday @midnight.

My goal here is to write a script(preferably shell script) to
increment the version number in 'projectname.rc' file and then commit
that modification to SVN every time I build successfully.

I know shell scripting. But
1) How to call the shell script from Jenkins?
2) How can I access 'projectname.rc' file from the script?
3) How to commit the modification( the script has done) to SVN?

Thanks in advance.

Daniel Beck

unread,
Dec 10, 2013, 5:54:25 AM12/10/13
to jenkin...@googlegroups.com
While not exactly what you're asking for, there's a tool that allows replacing placeholders with SVN information, such as revision, included in TortoiseSVN.

http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-subwcrev.html

This might be a better idea than committing build numbers, depending on your requirements.
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

AVee

unread,
Dec 10, 2013, 8:28:53 AM12/10/13
to jenkin...@googlegroups.com
As Daniel suggested, setting the buildnumber during the build might be a
better idea. We specifically do this make sure only 'official' builds
have proper build numbers.
Regardless, you could use svnAnt in an ant script get the subversion
revision, and optionally to commit the result of the replacement. This
is what we use in an ant script (for a .net application):

<svn refid="svnBspaas">
<wcversion path="${svnDir}"/>
</svn>

<echo message="Updating version to
${env.SPAAS_VERSION}.${env.BUILD_NUMBER}.${revision.max}"/>
<fileset id="PropInfo" dir="${env.WORKSPACE}"
includes="**/Properties/AssemblyInfo.cs" />

<replaceregexp match='(AssemblyVersion[^"]*").*"\)]'
replace='\1${env.SPAAS_VERSION}.${env.BUILD_NUMBER}.${revision.max}")]'
byline="true">
<fileset refid="PropInfo"/>
</replaceregexp>

AVee
Reply all
Reply to author
Forward
0 new messages