Using Jenkins with Eiffel

by Manu (modified: 2014 Feb 24)

Using Jenkins is a great tool and we are using it at Eiffel Software to perform regression testing. The goal of this article is to show you how to verify that your Eiffel code always compile fine.

Requirements

  • Jenkins 1.551 or later
  • EiffelStudio 14.05.9.4490 or later

Setup

First you need to create a new job item in Jenkins. For that you will choose to build multi-configuration project. Per the documentation, it is suitable for projects that need a large number of different configurations, such as testing on multiple environments, platform-specific builds, etc.

Under Configuration matrix we are going to define 2 user-defined axis:

  • platform with value unix and windows
  • source_path with the values of your choosing, it will be the locations where to find the source

Then you will add a build step "Execute Shell" with the following content:

echo "Creating a temporary directory where all the temporary files will be stored." dir=`mktemp -d` && cd $dir echo "To avoid any issue with precompiled libraries for various platforms, we set the path of the precompiled libraries." export ISE_PRECOMP=$dir/precomp failure=0 $ISE_EIFFEL/tools/spec/$ISE_PLATFORM/bin/compile_all -l $source_path -compdir $dir -ecb -melt -clean -options dotnet=false,platform=$platform || failure=1 rm -rf $dir if [ $failure -eq 1 ]; then echo Failed exit 1 fi

This shell script will execute compile_all, a tool of the EiffelStudio delivery, compiling all ECF files located under $source_path that are not made for .NET and compiling them for the chosen $platform.

Current the possible values for platform are:

  • unix
  • windows
  • macintosh
  • vxworks

When there is an ECF file that fails to compile, compile_all will return an error code which will mark the jenkins job as failed. When there is a failure we catch the failure, delete the temporary directory and report the failure to the shell. If we were not doing that, after a failure, it will stop executing the commands after compile_all and we would be left with many temporary directories.

The beauty of the multi-configuration project is that you can provide various source locations via source_path and it will basically compile them in parallel when you launch the job from the jenkins interface. Below is an example of the multi-configuration project we use at Eiffel Software, where each row corresponds to a particular source location and the column the platform for which it is compiled:

Jenkins job page

In this particular case, everything compiled except the configuration files under $EIFFEL_SRC/web. If your use the Matrix Reloaded extension, you can choose to just run the failed entries of the matrix after having fix the particular problem they raised by failing in the first place.

It is a very simple process and we can only recommend you to do the same.

Comments
  • Anders Persson (10 years ago 4/3/2014)

    Running Auto Test Cases

    I am using ec to compile and then run the auto test cases

    ec -config project.ecf -target project_c -loop 0<BuildAndTest.txt

    • Jocelyn-Fiat (10 years ago 4/3/2014)

      To run autotest from command line you can also do

         ec -config project.ecf -target project_c  -clean -c_compile -tests 
      • the -clean to clean any previous compilation.
      • -c_compile: to be sure the C code is compiled
      • and -tests to run the autotest cases.
  • Paul Gokke (9 years ago 18/8/2014)

    Build multiple targets from the same environment?

    Is it possible to install EiffelStudio on one environment and build for different targets (reading this article I get the feeling this is possible). For example an Eiffel Vision based application which is supposed to run on both Windows and Apple Macintosh target environments? If so, can you point me directions where I can find more information to set this up (my case would be to install EiffelStudio in a Windows environment and then build for Windows 32, 64 bit and Mac Ios ?

    Regards, Paul.

    • Manu (9 years ago 19/8/2014)

      Yes

      We now have a -platform option on the EiffelStudio command line compiler. It enables you to generate the C code of a program for a given platform. So if you specify unix, it will build the UNIX code, windows the Windows code. The other valid options are macintosh and vxworks. Once you have the C code, you take it to your platform of choice and then call finish_freezing on it. Meaning that you need an installation of EiffelStudio for all the platforms you want to target, but at least you can compile all the projects on just one platform.