A while back I posted a movie on installing and configuring CruiseControl on Windows, so I figured I’d give a brief overview in Linux. I am using Ubuntu so some of the examples may be different for you — depending on the UNIX/Linux flavor you’re using. This assumes that Java is in your system’s path. To verify, type:

echo $JAVA_HOME -or-
echo $PATH

Step 1
Download CruiseControl to a temporary location.

Step 2
Extract it to the location you wish to install it. For example:

unzip cruisecontrol.zip /opt

Step 3
Create a user and group and ensure that CruiseControl files are owned by this group. For instance, as root, create a cimasters group and a cimaster user:

/usr/sbin/useradd -G cimasters cimaster

If /usr/sbin/ has been added to your path, you only need to enter useradd.

Now, change the owner of all CruiseControl files like this:


chown cimaster:cimasters /opt/cruisecontrol-bin-2.6.1 -R

Step 4
Create a file to run CruiseControl as a service. This is based on the CruiseControl service code from the CruiseControl wiki.

#!/bin/sh
CC_USER=cimaster
CC_INSTALL_DIR=/opt/cruisecontrol-bin-2.6.1
CC_WORK_DIR=$CC_INSTALL_DIR
CC_LOGFILE_DIR=$CC_INSTALL_DIR
export JAVA_HOME=/opt/jdk1.5.0_11
PATH_ADDITIONS=
CC_WEBPORT=8484
CC_JMXPORT=8888
CC_RMIPORT=
NAME=cruisecontrol
DESC="CruiseControl - continuous integration build loop"
PATH=/opt/jdk1.5.0_11/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/bin:/bin
if [ -n "$PATH_ADDITIONS" ]; then
PATH=$PATH_ADDITIONS:$PATH
fi
export PATH
CC_DAEMON=$CC_INSTALL_DIR/cruisecontrol.sh
CC_CONFIG_FILE=$CC_INSTALL_DIR/config.xml
CC_LOG_FILE=$CC_LOGFILE_DIR/cruisecontrol.log
CC_COMMAND="cd $CC_WORK_DIR; $CC_DAEMON -configfile $CC_CONFIG_FILE -webport $CC_WEBPORT -jmxport $CC_JMXPORT"
if [ -f /etc/default/cruisecontrol ]; then
. /etc/default/cruisecontrol
fi
test -f $CC_DAEMON || (echo "The executable $CC_DAEMON does not exist!" && exit 0)
if [ `id -u` -ne 0 ]; then
echo "Not starting/stopping $DESC, you are not root."
exit 4
fi
PARPID=`ps -ea -o "pid ppid args" | grep -v grep | grep "${CC_DAEMON}" | sed -e 's/^ *//' -e 's/ .*//'`
if [ "${PARPID}" != "" ]
then
PID=`ps -ea -o "pid ppid args" | grep -v grep | grep java | grep "${PARPID}" | \
sed -e 's/^ *//' -e 's/ .*//'`
fi
case "$1" in
'start')
env >> cc.startup.env
su $CC_USER -c "/bin/sh -c \"$CC_COMMAND >> $CC_LOG_FILE 2>&1\"" & RETVAL=$?
echo "$NAME started with jmx on port ${CC_JMXPORT}"
;;
'stop')
if [ "${PID}" != "" ]; then
kill -9 ${PID} ${PARPID}
$0 status
RETVAL=$?
else
echo "$NAME is not running"
RETVAL=1
fi
;;
'status')
# echo PARPIDs $PARPID
# echo PIDs $PID
kill -0 $PID >/dev/null 2>&1
if [ "$?" = "0" ]; then
echo $NAME \(pids $PARPID $PID\) is running
RETVAL=0
else
echo "$NAME is stopped"
RETVAL=1
fi
;;
'restart')
$0 stop && $0 start
RETVAL=$?
;;
*)
echo "Usage: $0 { start | stop | status | restart }"
exit 1
;;
esac
#echo ending $0 $$....
exit 0

Name this file cruisecontrol and place it in the /etc/init.d directory. Then, type:
./cruisecontrol start

Open your browser to http://localhost:8484/ (or whichever port you chose).
CruiseControl on Ubuntu Linux
That should do it. Let me know if you have any questions.