Search code examples
dockerjenkinsrobotframework

How to add Robot Framework, Selenium, browser-test-support to a docker container?


How can I add the Robot Framework to a Docker image? I am already using a Jenkins image with Maven, etc.

I have reviewed quite a number of posts, but (as far as I understand) no complete set of actions adding 1 layer to a docker image via a Dockerfile.

After having this expanded container, I could execute shell script commands that start the tests via 'robot ... '. It should also run with the Firefox browser.

The advantage of adding RF to this container is that after a crash a fresh new image/container is created very easily.

As I understand, afterwards I add and can use the Robot Framework plugin to display the reports.

My current Dockerfile contains Jenkins, Docker (reference), docker-compose, Maven and Npm. Works great!

FROM jenkins/jenkins:lts
USER root

... docker

ENV MAVEN_VERSION 3.5.4
RUN curl -fsSL http://archive.apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar xzf - -C /usr/share \
  && mv /usr/share/apache-maven-$MAVEN_VERSION /usr/share/maven \
  && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

ENV MAVEN_HOME /usr/share/maven
COPY settings.xml /root/.m2/settings.xml

RUN apt-get install -y curl \
  && curl -sL https://deb.nodesource.com/setup_9.x | bash - \
  && apt-get install -y nodejs \
  && curl -L https://www.npmjs.com/install.sh | sh

user jenkins

Solution

  • After investigating a number of existing docker images with Robot Framework, I saw that for testing at the Browser level, there were some additions needed, like chromedriver, geckodriver and headless browsers.

    To add all this software to my existing Jenkins image would grow the image far beyond 1 Gig. That is really too much. Second reason for leaving this appraoch: the general Jenkins image will only execute Functional Tests in specific cases, so not always.

    So, the second approach I took was starting Robot Framework tests from a Jenkinsfile. I found a good existing Docker image with Robot Framework and drivers. The complete and working solution can be found in the post with this Jenkinsfile.

    And the results of Robot Framework tests? The status is shown via the console (like pass/fail). The rest of the information is available via the (archived) log.html and other html files. The Robot framework Plugin was not needed. Works like charm!