Robot Framework Tutorial 2016 – Integration with TeamCity CI-Server

No Comments

Robot Framework Tutorial 2016

Part 1: Installation
Part 2: Keywords
Part 3: Implementing Keywords in Java
Part 4: Selenium2Library as a drop-in replacement for SeleniumLibrary
Part 5: Integration with TeamCity CI-Server
Part 6: Integration with Jenkins
Part 7: File Processing

The “old” Robot Framework Tutorial.

Test automation without integration to a CI-Server is somehow quite meaningless. Therefore this blog post – and the next one – is about integrating the Robot Framework to different CI-Platforms. And as we are often using Jenkins as a CI-Server I thought it would be nice to start with something different. Therefore let’s integrate the Robot Framework to TeamCity CI-Server for a starter.


Typically the Robot Framework is installed on the same server as the CI-Platform. This is also assumed in the following. Installation of the Robot Framework is explained quite extensively in one of the earlier blog posts of this series.

So let’s proceed to the installation of TeamCity. For OS X the installation package comes as a TAR-file that can be downloaded from here.

What can potentially go wrong? Let’s unpack the thing and start it.

tar xvf TeamCity-9.1.6.tar
cd TeamCity/bin
./runAll.sh start

Bummer! It just terminates with an error.

Thomass-MacBook-cc:bin thomasjaspers$ ./startup.sh 
Using CATALINA_BASE:   /Users/thomasjaspers/Documents/projects/codecentric/teamcity/TeamCity
Using CATALINA_HOME:   /Users/thomasjaspers/Documents/projects/codecentric/teamcity/TeamCity
Using CATALINA_TMPDIR: /Users/thomasjaspers/Documents/projects/codecentric/teamcity/TeamCity/temp
Using JRE_HOME:        /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Using CLASSPATH:       /Users/thomasjaspers/Documents/projects/codecentric/teamcity/TeamCity/bin/bootstrap.jar:/Users/thomasjaspers/Documents/projects/codecentric/teamcity/TeamCity/bin/tomcat-juli.jar
touch: /Users/thomasjaspers/Documents/projects/codecentric/teamcity/TeamCity/logs/catalina.out: No such file or directory
/Users/thomasjaspers/Documents/projects/codecentric/teamcity/TeamCity/bin/catalina.sh: line 385: /Users/thomasjaspers/Documents/projects/codecentric/teamcity/TeamCity/logs/catalina.out: No such file or directory

But this does not look to hard to fix. After creating the missing log-directory the server just starts up smoothly. It can be accessed under http://localhost:8111/mnt and shows a nice welcome screen.


Well, as there are not too many choices let’s continue by pressing “Proceed”. On the next screen a database for storing job data must be configured. With PostgreSQL, Oracle, MySql and MS SQL Server there should be a convenient option available for everyone. For the purpose of this blog post the HSQLDB option was chosen. But this one is not recommended for productive use. After proceeding the initialization phase just takes forever. A quick look to the catalina.out log file shows the cause of the problem:

[2016-04-15 10:21:05,140]   WARN -   jetbrains.buildServer.SERVER - Cannot schedule running builds status re-calculation task, error: java.lang.RuntimeException: java.lang.OutOfMemoryError: PermGen space 

Ok, I admit that a look to the documentation tells to adjust the server settings before first startup. So let’s do this by setting some proper memory values (you would probably like to do this permanently in some script).

export TEAMCITY_SERVER_MEM_OPTS="-Xmx750m -XX:MaxPermSize=270m"

As the server still refuses to start up properly let’s take a look for some leftover processes. And indeed there is one process still running even after stopping the TeamCity server. So let’s kill it.

Thomass-MacBook-cc:bin thomasjaspers$ ps
  PID TTY           TIME CMD
  337 ttys000    0:00.01 -bash
  353 ttys001    0:00.02 -bash
  362 ttys002    0:00.02 -bash
  369 ttys003    0:00.01 -bash
  376 ttys004    0:00.01 -bash
  383 ttys005    0:00.01 -bash
  394 ttys006    0:00.01 -bash
  401 ttys007    0:00.01 -bash
  408 ttys008    0:00.36 -bash
 6042 ttys008   69:40.56 /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java -Djava.util.logging.config.file=/Users/thomasjaspers/Documents/projects/codecentric/teamcity/TeamCity/con
  415 ttys009    0:00.08 -bash
  422 ttys010    0:00.01 -bash
Thomass-MacBook-cc:bin thomasjaspers$ kill -9 6042

And just to be on the save side let’s cleanup the “.BuildServer”-directory under the home-directory of the user starting the TeamCity server.

Now when starting over again everything runs smoothly and after accepting the license agreement and creating an administrator user the TeamCity settings page shows up.



Disclaimer I: Even though there are some problems in setting up the TeamCity-Server it feels good as the problems could be easily found and fixed.
Disclaimer II: The intention of this blog post is not to do a full-fledged introduction to TeamCity. It is more about getting TeamCity up and running to be able to show the integration with the Robot Framework.

That’s it for the installation part. Let’s proceed and create a job executing some Robot Framework Tests :-).

Creating a new Build Job

Just some praise upfront. Setting up a trivial project that is executing some Robot Framework tests went really smooth. And today is my first time working with TeamCity, pretty amazing I would say. But let’s take a look step by step.

Let’s start by creating a new project providing some basic information.


This leads to the “Project Settings” page where we need to create a new build configuration.


Here again we need to provide some basic information …


… before we can proceed defining a “Build Step”. (Configuring any VCS access is intentionally skipped here.)


Now comes the interesting part. That is executing some Robot Tests.


It is really easy and very similar to executing Robot Tests using other CI-Servers. As the Robot Framework is typically anyway executed using the command line choosing “CommandLine” for the “Execution Type” is quite natural. Running it as a “Custom Script” is again very easy. In a real project you would probably wrap everything into a single shell script. But still the amount of needed commands is quite manageable in the above example. That example is btw. based on the examples described in this blog post (those can also be found from GitHub directly).


Ok, let’s proceed with …

Executing the Tests

Nothing easier than that: Just press the “Run” button shown at the top of the page and the tests are getting executed. Results show that tests have been executed successfully.


But of course we would like to see more details, just to be sure. This can be done under “Build Log” by opening the “Executing Tests” folder. There we can see the typical Robot Framework output.


Of course we do not want to execute the tests manually. So let’s configure some scheduled execution. This can be done under “Triggers -> Add new Trigger”.


Probably no need to dig into all possible details here. Again the configuration is really straightforward.
But one important part is still missing here: Integrating the reporting capabilities of the Robot Framework to TeamCity build execution.

Integrating Robot Framework Reports

As there is no dedicated Robot Framework PlugIn available for TeamCity we need to find another way for some nice integration. Luckily Including 3rd party reports sounds exactly like the thing we are looking for.

Therefore let’s configure the Robot Framework log- and report-files as resulting artifacts of the build. This can be easily done by adding them to the “Artifact paths” as follows.


Those can then be accessed directly from the project-overview page by clicking on “Artifacts”.


This leads to the following page where the HTML-files can be opened directly.


But we can still do better by configuring a custom report page. We only need to point to the “report.html” and give the new tab a nice name like “Robot Framework Results”.


Once the configuration is done a new tab is shown when digging into the project.


By simply clicking on the new reporting tab we immediately get the resulting Robot Framework report.


Pretty nice, isn’t it? And due to the fact that the report- and the logfile-artifacts are published to the same directory we can directly dig into the logfile from here.


That’s it … and what an insane amount of screenshots :-).


Well, the summary can be pretty short this time. Integrating the Robot Framework to TeamCity is really straightforward. And I really like the ease of using TeamCity :-).


Your email address will not be published. Required fields are marked *