Before following this post you need an SVN server (post here) and a CruiseControl server (post here and here).
1. Create a special account, on the SVN server, for getting the source code from the CC server.
The objective here is to do something similar to what is described at http://svn.collab.net/repos/svn/trunk/notes/ssh-tricks
1.1. [SVN Server] On the SVN server:
1.1.1. Add two new SVN access accounts, but without shell access:
#---
useradd svn-ro
useradd svn-rw
usermod --lock svn-ro
usermod --lock svn-rw
#---
1.1.2. Verify if the SSH daemon is setup to accept public key authentication: /etc/ssh/sshd_config
It must have a line with:
PubkeyAuthentication yes
1.2. [CC Server] On the CC server:
1.2.1. Setup the key pair for the cruise user, to be used to authenticate at the SVN server (see documentation here):
a. Enter an EMPTY passphrase for the ssh key pair:
#---
mkdir ~cruise/.ssh
ssh-keygen -q -f ~cruise/.ssh/id_rsa -t rsa
#---
b. Let the user have access to own keys, but only this user:
#---
chmod -R go-rwx ~cruise/.ssh
chown -R cruise:cruise ~cruise/.ssh
#---
1.2.3. Copy the public key to the SVN server, at the svn-ro user home dir (remember that svn-ro user has no shell access, so do NOT try to transfer the key using the svn-ro account).
#---
scp ~cruise/.ssh/id_rsa.pub <user that HAS shell access in the SVN server>@<SVN server>:
#---
1.3. [SVN Server] Back at the SVN server:
1.3.1. Add the public key to the svn access user's (svn-ro) authorized key ring:
#---
mkdir -p ~svn-ro/.ssh/
mkdir -p ~svn-rw/.ssh/
cat ~<user used to deploy the public key>/id_rsa.pub >> ~svn-ro/.ssh/authorized_keys
cat ~<user used to deploy the public key>/id_rsa.pub >> ~svn-rw/.ssh/authorized_keys
chown -R svn-ro:svn-ro ~svn-ro/.ssh/
chmod -R go-rwx ~svn-ro/.ssh/
chown -R svn-rw:svn-rw ~svn-rw/.ssh/
chmod -R go-rwx ~svn-rw/.ssh/
#---
1.3.2. Edit the authorization key ring file: ~svn-ro/.ssh/authorized_keys AND ~svn-rw/.ssh/authorized_keys
a. It looks like this:
ssh-rsa AAAA<a lot more chars>= root@<CC server name>
b. change it to this:
command="/usr/bin/svnserve -t",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa AAAA<a lot more chars>= root@<CC server name>
1.4. [CC Server] Back to the CC server:
1.4.1. Create the necessary directories for the CC:
#---
mkdir -p /var/spool/cruisecontrol/{projects,logs,artifacts}
chown -R cruise:cruise /var/spool/cruisecontrol/
#---
1.4.1. Try to access the SVN server:
#---
su - cruise
svn list svn+ssh://svn-ro@<SVN server>/var/svn/
logout
#---
2. Configuring a project to be managed under the CC policy:
a. Local working copy (for the CruiseControl): /var/spool/cruisecontrol/projects
b. Special SVN repository for the CruiseControl configuration and building ANT scripts: /var/svn/cruisecontrol
c. A special SVN Project (under the /var/svn/trunk) to hold the main build and JUnit ANT scripts, that is called Master here
2.1. [SVN Server] Create the new CC root at the SVN
#---
svn mkdir -m "Initial setup: CruiseControl development tree" file:///var/svn/cruisecontrol
#---
2.4. [Dev Workstation] Create a project, named Main, and commit/import it to svn+ssh://<SVN server>/var/svn/cruisecontrol
Note.: This project must contain at least one file called build-cc.xml.
2.5. [SVN Server] To keep it simple:
#---
su - <A regular dev user>
mkdir Main
cd Main
cat > build-cc.xml << __END__
<project basedir="." default="main" name="Main">
<target name="main">
<echo message="Working"/>
</target>
</project>
__END__
svn import -m "Initial CruiseControl build file" file:///var/svn/cruisecontrol/Main
#---
2.6. [CC Server] Checkout the CC root from the SVN at the local working dir: /var/spool/cruisecontrol/projects
#---
su - cruise
svn checkout svn+ssh://svn-ro@<SVN Server>/var/svn/cruisecontrol/Main projects/Main
logout
#---
2.3. [CC Server] Create a new config.xml
[UPDATE: NOT WORKING PROPERLY] (Thanks to Leif, see comments below).
#---
cat > /etc/cruisecontrol/config.xml << __END__
<cruisecontrol>
<property name="cruise.working.dir" value="/var/spool/cruisecontrol" />
<property name="cruise.log.dir" value="\${cruise.working.dir}/logs" />
<property name="cruise.projects.dir" value="\${cruise.working.dir}/projects" />
<property name="svn.sandbox.username" value="svn-ro" />
<plugin name="basicproject" classname="net.sourceforge.cruisecontrol.ProjectConfig">
<labelincrementer defaultLabel="\${project.name}-1"
separator="-" />
<listeners>
<currentbuildstatuslistener
file="\${cruise.log.dir}/\${project.name}/status.txt" />
</listeners>
<modificationset quietperiod="30">
<svn LocalWorkingCopy="\${cruise.projects.dir}/\${project.name}" />
</modificationset>
<log>
<merge
dir="\${cruise.working.dir}/projects/\${project.name}/target/test-results" />
</log>
<publishers>
<artifactspublisher
file="\${cruise.working.dir}/projects/\${project.name}/target/\${project.name}.jar"
dest="\${cruise.working.dir}/artifacts/\${project.name}" />
</publishers>
</plugin>
<!-- here you can change the project name, if you decided from something else -->
<project name="Main" buildafterfailed="yes"
forceBuildNewProject="yes">
<bootstrappers>
<svnbootstrapper localWorkingCopy="\${cruise.projects.dir}/\${project.name}"
userName="\${svn.sandbox.username}" />
</bootstrappers>
<schedule interval="10">
<ant antWorkingDir="\${cruise.projects.dir}/\${project.name}"
buildfile="build-cc.xml" />
</schedule>
</project>
</cruisecontrol>
__END__
#---
[UPDATE]
2.4. [CC Server] Restart the server and check if it worked by accessing: http://localhost:8080/dashboard/
3. Have fun, configuring the build-cc.xml and organising your repository and code :-)
Related posts:
Subversion and Apache with PAM
CruiseControl on Fedora: Setup
CruiseControl on CentOS: Setup
Showing posts with label cruisecontrol. Show all posts
Showing posts with label cruisecontrol. Show all posts
Friday, August 14, 2009
CruiseControl on CentOS: Setup
In this post I want to present a simple way to install and configure CruiseControl (hereafter just CC) to run on CentOS. For the configuration part, please refer to the Fedora procedure, since it is the same. The only difference is in how to install the CC to be similar to the RPM instalation.
1. Since I could not find any RPM specific for CentOS I have taken the binaries available at CC home-page: http://cruisecontrol.sourceforge.net/download.html
You will also need the following packages:
#---
yum -y install \
ant
#---
And Sun's Java JDK: http://java.sun.com/javase/downloads
2. Decompress the binary package from CC into /opt dir:
#---
unzip cruisecontrol-bin-<VERSION>.zip -d /opt/
ln -s /opt/cruisecontrol-bin-<VERSION> /opt/cruisecontrol
#---
3. Edit the starting script at: /opt/cruisecontrol/cruisecontrol.sh
3.1. Add the following lines, right after the commented CC_OPTS variable:
JAVA_HOME="/usr/java/default/jre"
PATH=${JAVA_HOME}/bin:${PATH}
3.2. Check if the default port is free:
#---
nc -z localhost 8080 || echo "Port is free" # default cruise control port AND tomcat's default port, watch this out
#---
OBS.: It MUST yeld NOTHING. If it returns a "succeeded" it means that the port is occupied and you need to change it to another one.
3.3. Change the final calling statements for:
#---
cat >> /opt/cruisecontrol/cruisecontrol.sh << __END__
# PAY ATTENTION: you ABSOLUTELY need to change the argument in the \"-webport\" if the port 8080 is already occupied
CMD="JAVA_HOME=\${JAVA_HOME:-/usr} \\
PATH=\${JAVA_HOME:-/usr}/bin:\$PATH \\
CC_OPTS=\"\${CRUISE_OPTS:-}\" \\
\$JAVA_HOME/bin/java \\
-Djavax.management.builder.initial=mx4j.server.MX4JMBeanServerBuilder \\
\"-Dcc.library.dir=\$LIBDIR\" \\
\"-Djetty.logs=$JETTY_LOGS\" \\
-jar \"\$LAUNCHER\" \$@ \\
-configfile /etc/cruisecontrol/config.xml \\
-jmxport \${CRUISE_JMX_PORT:-8000} \\
-rmiport \${CRUISE_RMI_PORT:-1099} \\
-webport \${CRUISE_WEB_PORT:-8080} \\
&"
echo \$CMD
# necessary to make the "out-of-box" version work regardless of the calling point
cd /var/spool/cruisecontrol/
eval \${CMD}
echo \$! > /var/spool/cruisecontrol/cc.pid
__END__
mv /opt/cruisecontrol/cruisecontrol.sh /opt/cruisecontrol/cruisecontrol2.sh
cat > /opt/cruisecontrol/cruisecontrol.sh << __END__
#!/bin/sh
su - cruise -c /opt/cruisecontrol/cruisecontrol2.sh
__END__
chmod 755 /opt/cruisecontrol/cruisecontrol.sh
#---
4. Add the cruise user:
#---
groupadd cruise
useradd \
--comment "CruiseControl User" \
--home-dir "/var/spool/cruisecontrol" \
--gid cruise \
--shell /bin/bash \
cruise
#---
5. Verify if CC is running:
#---
/opt/cruisecontrol/cruisecontrol.sh
#---
5.1. Check if it is up and running by accessing: http://localhost:8080/dashboard (remember that if you changed the default port the value 8080 must be changed as well).
5.2. If it is up and running you may want to make it starts when the server starts:
#---
cat >> /etc/rc.local << __END__
# starts the CruiseControl
/opt/cruisecontrol/cruisecontrol.sh
__END__
#---
Related post: CruiseControl on Fedora: Setup
1. Since I could not find any RPM specific for CentOS I have taken the binaries available at CC home-page: http://cruisecontrol.sourceforge.net/download.html
You will also need the following packages:
#---
yum -y install \
ant
#---
And Sun's Java JDK: http://java.sun.com/javase/downloads
2. Decompress the binary package from CC into /opt dir:
#---
unzip cruisecontrol-bin-<VERSION>.zip -d /opt/
ln -s /opt/cruisecontrol-bin-<VERSION> /opt/cruisecontrol
#---
3. Edit the starting script at: /opt/cruisecontrol/cruisecontrol.sh
3.1. Add the following lines, right after the commented CC_OPTS variable:
JAVA_HOME="/usr/java/default/jre"
PATH=${JAVA_HOME}/bin:${PATH}
3.2. Check if the default port is free:
#---
nc -z localhost 8080 || echo "Port is free" # default cruise control port AND tomcat's default port, watch this out
#---
OBS.: It MUST yeld NOTHING. If it returns a "succeeded" it means that the port is occupied and you need to change it to another one.
3.3. Change the final calling statements for:
#---
cat >> /opt/cruisecontrol/cruisecontrol.sh << __END__
# PAY ATTENTION: you ABSOLUTELY need to change the argument in the \"-webport\" if the port 8080 is already occupied
CMD="JAVA_HOME=\${JAVA_HOME:-/usr} \\
PATH=\${JAVA_HOME:-/usr}/bin:\$PATH \\
CC_OPTS=\"\${CRUISE_OPTS:-}\" \\
\$JAVA_HOME/bin/java \\
-Djavax.management.builder.initial=mx4j.server.MX4JMBeanServerBuilder \\
\"-Dcc.library.dir=\$LIBDIR\" \\
\"-Djetty.logs=$JETTY_LOGS\" \\
-jar \"\$LAUNCHER\" \$@ \\
-configfile /etc/cruisecontrol/config.xml \\
-jmxport \${CRUISE_JMX_PORT:-8000} \\
-rmiport \${CRUISE_RMI_PORT:-1099} \\
-webport \${CRUISE_WEB_PORT:-8080} \\
&"
echo \$CMD
# necessary to make the "out-of-box" version work regardless of the calling point
cd /var/spool/cruisecontrol/
eval \${CMD}
echo \$! > /var/spool/cruisecontrol/cc.pid
__END__
mv /opt/cruisecontrol/cruisecontrol.sh /opt/cruisecontrol/cruisecontrol2.sh
cat > /opt/cruisecontrol/cruisecontrol.sh << __END__
#!/bin/sh
su - cruise -c /opt/cruisecontrol/cruisecontrol2.sh
__END__
chmod 755 /opt/cruisecontrol/cruisecontrol.sh
#---
4. Add the cruise user:
#---
groupadd cruise
useradd \
--comment "CruiseControl User" \
--home-dir "/var/spool/cruisecontrol" \
--gid cruise \
--shell /bin/bash \
cruise
#---
5. Verify if CC is running:
#---
/opt/cruisecontrol/cruisecontrol.sh
#---
5.1. Check if it is up and running by accessing: http://localhost:8080/dashboard (remember that if you changed the default port the value 8080 must be changed as well).
5.2. If it is up and running you may want to make it starts when the server starts:
#---
cat >> /etc/rc.local << __END__
# starts the CruiseControl
/opt/cruisecontrol/cruisecontrol.sh
__END__
#---
Related post: CruiseControl on Fedora: Setup
CruiseControl on Fedora: Setup
In this post I want to present a simple way to install and configure CruiseControl (hereafter just CC) to run on Fedora. It is NOT my objective to teach you how to each and every option of the configuration file works. For that you have plenty of other sources, such as the official documentation (here) and a pretty good step-by-step install, configure, and use documentation at JavaRanch (here). My objective is to give you an example of how to install and configure a CC server. (I'm one of those guys that learn better with an example.) Feel free to adapt it to your necessities.
http://cruisecontrol.sourceforge.net/main/configxml.html
http://www.javaranch.com/journal/200409/DrivingOnCruiseControl_Part1.html
1. Since I could not find any RPM specific for Fedora I have taken the RPM for OpenSUSE from RPMpbone.net (package list here and here):
You will also need the following packages:
#---
yum -y install \
ant
#---
And Sun's Java JDK: http://java.sun.com/javase/downloads
2. Setup the CC service.
Set it to use the Sun Java (it has serious problem with openJDK) by editing the file: /etc/default/cruisecontrol and including the following lines, before the final line
JAVA_HOME="/usr/java/default/jre"
PATH=${JAVA_HOME}/bin:${PATH}
2.1. Check if the default port is free:
#---
nc -z localhost 8080 # default cruise control port AND tomcat's default port, watch this out
#---
OBS.: It MUST yeld NOTHING. If it returns a "succeeded" it means that the port is occupied and you need to change it to another one. You can change it by given another port number for the variable CRUISE_WEB_PORT in the file: /etc/default/cruisecontrol
2.2. Start the CC daemon:
#---
service cruisecontrol start
#---
2.3. Check if it is up and running by accessing: http://localhost:8080/dashboard (remember that if you changed the default port the value 8080 must be changed as well).
2.4. If it is up and running you may want to make it starts when the server starts:
#---
chkconfig --level 345 cruisecontrol
#---
Related post: CruiseControl on CentOS: Setup
http://cruisecontrol.sourceforge.net/main/configxml.html
http://www.javaranch.com/journal/200409/DrivingOnCruiseControl_Part1.html
1. Since I could not find any RPM specific for Fedora I have taken the RPM for OpenSUSE from RPMpbone.net (package list here and here):
You will also need the following packages:
#---
yum -y install \
ant
#---
And Sun's Java JDK: http://java.sun.com/javase/downloads
2. Setup the CC service.
Set it to use the Sun Java (it has serious problem with openJDK) by editing the file: /etc/default/cruisecontrol and including the following lines, before the final line
JAVA_HOME="/usr/java/default/jre"
PATH=${JAVA_HOME}/bin:${PATH}
2.1. Check if the default port is free:
#---
nc -z localhost 8080 # default cruise control port AND tomcat's default port, watch this out
#---
OBS.: It MUST yeld NOTHING. If it returns a "succeeded" it means that the port is occupied and you need to change it to another one. You can change it by given another port number for the variable CRUISE_WEB_PORT in the file: /etc/default/cruisecontrol
2.2. Start the CC daemon:
#---
service cruisecontrol start
#---
2.3. Check if it is up and running by accessing: http://localhost:8080/dashboard (remember that if you changed the default port the value 8080 must be changed as well).
2.4. If it is up and running you may want to make it starts when the server starts:
#---
chkconfig --level 345 cruisecontrol
#---
Related post: CruiseControl on CentOS: Setup
Subscribe to:
Posts (Atom)