Jenkins

From Free Pascal wiki
Revision as of 08:23, 8 October 2012 by BigChimp (talk | contribs) (Added windres resource compiler)

Overview

Jenkins is a continuous integration server that can be used to automatically build and test projects based on commits to your source control system.

Use with FPC/Lazarus

This section describes how to set up Jenkins to automatically build FPC when a commit happens in SVN.

Jenkins set up

A possible version to use is Turnkey Linux Jenkins on Debian 6.0.5 (Squeeze)

Whichever way you install Jenkins, make sure the SVN plugin is enabled

Install binutils+stable FPC:

apt-get instal build-essential
#fpc would get old FPC 2.4 on this Debian Squeeze=> symptom in Jenkins build log: 
#generic.inc(2505,13) Fatal: Internal error 8
#Fatal: Compilation aborted
#make[7]: *** [system.ppu] Error 1

#get stable compiler (2.6 at time of writing); we're on a 32 bit system:
cd /root
wget http://sourceforge.net/projects/freepascal/files/Linux/2.6.0/deb/fp-compiler-2.6.0_2.6.0-0_i386.deb/download
mv download fp-compiler-2.6.0_2.6.0-0_i386.deb
wget http://sourceforge.net/projects/freepascal/files/Linux/2.6.0/deb/fp-compiler_2.6.0-0_i386.deb/download
mv download fp-compiler_2.6.0-0_i386.deb
wget http://sourceforge.net/projects/freepascal/files/Linux/2.6.0/deb/fp-units-rtl_2.6.0-0_i386.deb/download
mv download fp-units-rtl_2.6.0-0_i386.deb
wget http://sourceforge.net/projects/freepascal/files/Linux/2.6.0/deb/fp-units-rtl-2.6.0_2.6.0-0_i386.deb/download
mv download fp-units-rtl-2.6.0_2.6.0-0_i386.deb
wget http://sourceforge.net/projects/freepascal/files/Linux/2.6.0/deb/fp-units-i386-2.6.0_2.6.0-0_i386.deb/download
mv download fp-units-i386-2.6.0_2.6.0-0_i386.deb
wget http://sourceforge.net/projects/freepascal/files/Linux/2.6.0/deb/fp-units-i386_2.6.0-0_i386.deb/download
mv download fp-units-i386_2.6.0-0_i386.deb
wget http://sourceforge.net/projects/freepascal/files/Linux/2.6.0/deb/fp-utils-2.6.0_2.6.0-0_i386.deb/download
mv download fp-utils-2.6.0_2.6.0-0_i386.deb
wget http://sourceforge.net/projects/freepascal/files/Linux/2.6.0/deb/fp-utils_2.6.0-0_i386.deb/download
mv download fp-utils_2.6.0-0_i386.deb

dpkg -i fp-units-rtl-2.6.0_2.6.0-0_i386.deb
dpkg -i fp-units-rtl_2.6.0-0_i386.deb
dpkg -i fp-compiler-2.6.0_2.6.0-0_i386.deb
dpkg -i fp-utils-2.6.0_2.6.0-0_i386.deb
#no idea what the other .debs are for that we downloaded
#todo: this could be trimmed down a bit, but this seems to work

# Get resource compiler, not provided by fpc 2.6 packages:
apt-get install mingw32-binutils
# symlink:
ln -s /usr/bin/i586-mingw32msvc-windres /usr/bin/windres

Setting up jobs

Use the job screen to set the svn source to the FPC trunk or branch you want to use (e.g. http://svn.freepascal.org/svn/fpc/trunk)

Set 'use svn update as much as possible'

Polling every 5 minutes could be a good setup. Alternatively, you can set up your own SVN server and write a commit hook script for that. This would result in this entry:

# every 5 minutes
*/5 * * * *

As build commands, the shell commnds

make all

and, to install inside the "workspace" or top of the build directory environment:

make install PREFIX=$WORKSPACE

Note: installing somewhere else may be a good idea, please refer to the Build FAQ.

Make install does not generate an fpc.cfg for you; you have to do that yourself:

$WORKSPACE/bin/fpcmkcfg -o $WORKSPACE/bin/fpc.cfg

A problem: /etc/fpc.cfg

The stable we compiled using packages works, but puts an fpc.cfg into the /etc directory. This fpc.cfg is picked up by default and there is no way to disable that unless you e.g. call a script fpc.sh as your compiler instead of the fpc executable. This script passes options to the real compiler so it ignores /etc/fpc.cfg

This will give problems with running e.g. the compiler test suite.

The fpcup tool has done this (and more), so a solution could be:

  • get fpcu into your workspace
  • change build steps to call fpcup with --only=fpc --fpcrevision=$SVN_REVISION

We could have run fpcup so it downloads the latest SVN version, but then we lose the integration with subversion

Compiler test suite

Could not get the compiler test suite in <fpc>/tests working (October 2012). Corrections/additions welcome.


FPCUnit/DBTestframework tests

Enhancements

Possible enhancements:

  • run make clean before building!?!
  • run make install into a different prefix
  • run Lazarus compile
  • run dbtestframework test suite, save results (in database or via XML if Jenkins supports that)
  • add Windows (etc) build slaves
  • add installer builders
  • different repositories


Windows/Linux... build slave

You can set up other machines apart from the Jenkins server to act as "slaves": they are controlled from Jenkins and used to run jobs.

This can be useful when running a Windows build/test run from a Linux server.

See [1] for details on how to set up Windows build slaves via DCOM (note: there are other ways to set up (Windows) build slaves; please refer to the Jenkins documentation)