How to add SVN Label and Revision to Source while or after build (on Hudson)

, ,

I want to create a build, which creates a "version number". Version should include SVN Label and revision, preferable also Hudson build number.

Any "out of the box" functionality in Hudson or some plugin maybey ?

Thank you in advance.

Comments

You can invoke a script from hudson, this is only a segment of a typical script:

 

BUILD_TIME="`date +%F%t%R%t`" 

BUILD_NUMBER=`grep "build\." $MY_PATH/version.properties | mawk 'BEGIN { FS = "=" } ; { print $2 }'  | xargs | mawk '{print $2"."$3"."$1 +1 }' `

cd $REPO
svn info
echo Updating svn ... 
svn up $REPO 
echo Svn status ... 
svn stat
SVN_RETURN=`svnversion ${REPO}` 
echo
echo Trunk HEAD version is at $SVN_RETURN 


 

Hudson creates environment variables that you can use in your script (any script you call during the build), for example:

BUILD_NUMBER - The current build number, such as "153"
BUILD_ID - The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
JOB_NAME - Name of the project of this build, such as "foo"
BUILD_TAG - String of "hudson-${JOBNAME}-${BUILD_NUMBER}". Convenient to put into a resource file, a jar file, etc for easier identification.
SVN_REVISION - For Subversion-based projects, this variable contains the revision number of the module.