Nightly Build script

Linux, Software, subversion Add comments

We are setting up an complete new development, stagging environment.
And we decided to go with Subversion for Version Control.

And we needed a nightly build export script so I wrote a simple one.

#!/bin/sh
#########################################################################
#
# Implementation of subversion nightly build
#
# Author: Tim Haselaars
# Contact: tim.haselaars@trinix.be
# Date: 6/6/2007
# Version: 1.0
#
#########################################################################

#//////////////////////////////////////////////////////////////////#
# CONFIG SECTION
#//////////////////////////////////////////////////////////////////#

REPO_PATH=”/svn/repos/name”
TEMP_PATH=”/svn/tmp/name”
BUILD_PATH=”/svn/builds/name”

#//////////////////////////////////////////////////////////////////#
# CODE SECTION (do not change)
#//////////////////////////////////////////////////////////////////#
# Show me the current date
date=`date +%Y-%m-%d`

# Create essential directories
if [ ! -d $BUILD_PATH ] # be sure the directory /mnt exists
then
mkdir -pv $BUILD_PATH/{www,tar,zip,log}
fi

if [ ! -d $TEMP_PATH ] # be sure the directory /mnt exists
then
cp -r $REPO_PATH $TEMP_PATH
fi

# Get local snapshot copies revision number
OLD=`svn info file:///$TEMP_PATH | grep -r Revision | cut -f 2 -d ” “`

# Get current development revision number
NEW=`svn info file:///$REPO_PATH | grep -r Revision | cut -f 2 -d ” “`

# Compare for OLD and NEW revision
if [ $NEW -gt $OLD ] ; then

# update local copies
svn update file:///$TEMP_PATH

#Clean old build
rm -Rf $BUILD_PATH/www/

# create another local copies
cp -r file:///$TEMP_PATH $BUILD_PATH/www/

# Recursively remove all .svn directories from folder builds
find $BUILD_PATH/ -name .svn -print0 | xargs -0 rm -rf

# Create archive
tar czf $BUILD_PATH/tar/HIL5-revision-$NEW-$date.tar.gz $BUILD_PATH/www/
zip -r $BUILD_PATH/zip/HIL5-revision-$NEW-$date.zip $BUILD_PATH/www/

# Dumping svn commit log
svn log -v local > $BUILD_PATH/log/CHANGELOG

# Delete folder
#rm -rf

echo “New revision available on $date. Current is Revision $NEW” >> $BUILD_PATH/log/BUILDLOG
else
# If there’s no commit been made
echo “No new revision available on $date. Current is Revision $OLD” >> $BUILD_PATH/log/BUILDLOG
fi

One Response to “Nightly Build script”

  1. TRINIX » Blog Archive » Automated PHP API generator Says:

    [...] Next we are going to let our phpDocumentor do it’s work every night. So I have written a little plain export script and an extend our nightly build subversion script (see thim.trinix.be/2007/06/06/nightly-build-script/) [...]

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in