Running WebDriver Selenium tests on your Jenkins build server

So you have setup Jenkins as your build server and you test your project automated with Selenium WebDriver. Now you want to run the automated tests in a Jenkins job, but you get the following error:

. Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host on port 7055 after 45000 ms. Firefox console output:
. (process:26912): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
. Error: cannot open display: :1

This post explains how to fix this. The reason is that the user that runs your Jenkins service does not have a display. Therefore there is no possibility to open a browser like Firefox.

In order the facilitate this, we will use xvfb. This is a display server that performs all graphical user interface [GUI] operations in memory and without showing any screen output.

1. Install FireFox on the machine that runs Jenkins
In /etc/apt/sources.list add the following line.


Run the following commands to upgrade or install latest version of Firefox to work with Selenium.

sudo apt-get update
sudo apt-get install firefox

2. Install Xvfb on your server
Run the following command to install Xvfb on your server

apt-get install xvfb x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps

3. Install Xvfb in Jenkins
Install the Xvfb plugin
Schermafbeelding 2015-06-21 om 19.28.28

Configure the plugin via Manage Jenkins / Configure System
Schermafbeelding 2015-06-21 om 20.45.31

4. Configure Xvfb in your Jenkins job
Schermafbeelding 2015-06-21 om 20.45.54

Nexus: Remote host closed connection during handshake

If you have below exception, you should probably update Maven to a newer version!

Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Faile
d to retrieve remote metadata nl:parent:1.18-SNAPSHO
T/maven-metadata.xml: Could not transfer metadata nl:parent:1.18-SNAPSHOT/maven-metadata.xml from/to corporateRepo ( Remote host closed connectio
n during handshake
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(Def
at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDepl
at org.apache.maven.plugin.deploy.DeployMojo.deployProject(DeployMojo.ja
… 22 more
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to retriev
e remote metadata nl:parent:1.18-SNAPSHOT/maven-meta
data.xml: Could not transfer metadata nl:parent:1.18
-SNAPSHOT/maven-metadata.xml from/to corporateRepo (
xus/content/repositories/rib-snapshot): Remote host closed connection during han
at org.sonatype.aether.impl.internal.DefaultDeployer.upload(DefaultDeplo
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeplo
at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeplo
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(Defa
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(Def
… 24 more
Caused by: org.sonatype.aether.transfer.MetadataTransferException: Could not tra
nsfer metadata
a.xml from/to corporateRepo (
s/rib-snapshot): Remote host closed connection during handshake
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$3.wrap(W
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$3.wrap(W
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.
at org.sonatype.aether.util.concurrency.RunnableErrorForwarder$
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
at java.util.concurrent.ThreadPoolExecutor$
Caused by: org.apache.maven.wagon.TransferFailedException: Remote host closed co
nnection during handshake
at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInput
at org.apache.maven.wagon.StreamWagon.getInputStream(
at org.apache.maven.wagon.StreamWagon.getIfNewer(
at org.apache.maven.wagon.StreamWagon.get(
at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$GetTask.
… 4 more
Caused by: Remote host closed connection du
ring handshake
at org.apache.maven.wagon.providers.http.httpclient.impl.AbstractHttpCli
at org.apache.maven.wagon.providers.http.httpclient.impl.AbstractHttpCli
at org.apache.maven.wagon.providers.http.httpclient.impl.conn.AbstractCl
at org.apache.maven.wagon.providers.http.httpclient.protocol.HttpRequest
at org.apache.maven.wagon.providers.http.httpclient.protocol.HttpRequest
at org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultR
at org.apache.maven.wagon.providers.http.httpclient.impl.client.DefaultR
at org.apache.maven.wagon.providers.http.httpclient.impl.client.Abstract
at org.apache.maven.wagon.providers.http.httpclient.impl.client.Abstract
at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.execute(A
at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInput
… 8 more
Caused by: SSL peer shut down incorrectly
… 24 more

Run shell scripts on Jenkins as super user [sudo] without given too much privileges

You have a Jenkins build server and want to run a script which requires super user rights. But you do not want do make your jenkins user a super user.

With the following you give your jenkins user only sudo rights for a specific script.

In the /etc/sudoers file you can give sudo rights for a specific file to the user with which you run jenkins.
Schermafbeelding 2014-12-02 om 19.48.27

Then in your Jenkins job, you can sudo this script
Schermafbeelding 2014-12-02 om 19.48.46

Add a HTTPS certificate to your Java keychain

You have a tool like GIT or Maven that connects to a HTTPS website. Then your tool needs to know whether to trust that website’s certificate.

When that tool uses Java underneath, you can follow the following steps to add the website’s certificate to your keystore.

1) Visit the website [like for example] using Firefox.

2) (optional) Confirm and add the exception if you get the notification “This Connection is Untrusted”

3) Export the certificate to a file with the name “CompanyCA.pem” ( click on lock left next to the domain name -> More information -> View certificate -> Details -> Export (choose format “X.509 Certificate with chain PEM”))

Click on the lock
Schermafbeelding 2014-11-27 om 20.51.54

View the details
Schermafbeelding 2014-11-27 om 20.52.36

View the certificate
Schermafbeelding 2014-11-27 om 20.52.49

Export the certificate with format “X.509 Certificate with chain PEM”
Schermafbeelding 2014-11-27 om 21.24.46

4) Add the certificate to you cacerts keychain to the java version that maven uses via the following steps

4.1) Determine which java version your maven uses via
mvn –version

4.2) On the command line, go to the java directory via
cd < java home directory >

Note: when you use Windows, then you need to start the command prompt as “Run as administrator”.

4.3) open the lib/security directory within this folder
4.4) Add the website’s CA certificate to the cacerts keychain via
keytool -keystore cacerts -importcert -alias companyca -file < file directory >/CompanyCA.pem

Note Replace the placeholder < file directory > with the file location where you stored the pem certificate. If you are on a unix like system, then you need to prefix this command with sudo.

Provide your password. By default this is changeit
Schermafbeelding 2014-11-27 om 21.07.31

When asked to trust it, type yes
Schermafbeelding 2014-11-27 om 21.08.22

When the notification “Certificate was added to keystore” is shown without errors, then you are done!

Do ensure that in your settings.xml and your pom files, all links to you repository point to the https url, so for example

How do know your certificate is not trusted properly?
When you get one of the below exceptions…

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project parent: Failed to retrieve remote metadata Could not transfer metadata from/to corporateRepo ( peer not authenticated -> [Help 1]

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project parent: Failed to retrieve remote metadata Could not transfer metadata from/to corporateRepo ( PKIX path building failed: unable to find valid certification path to requested target -> [Help 1]

Store Subversion credentials in Maven

When you are using Subversion from the command line instead of via a tool like TortoiseSVN, then you do NOT want to provide your username and password everything again when you want to update or commit the code of your Maven project.

To ensure that your SVN never asks for the credentials again, you can set these in your settings.xml via below addition.

The ID needs to be the host of your Subversion repository. So, when your Subversion url is “″, then the id is “”.



An example of an error from the maven-release-plugin when the [proper] SVN credentials are not available.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project internet-portal-parent: Unable to commit files
[ERROR] Provider message:
[ERROR] The svn command failed.
[ERROR] Command output:
[ERROR] svn: E170001: Commit failed (details follow):
[ERROR] svn: E170001: Unable to connect to a repository at URL ''
[ERROR] svn: E170001: OPTIONS of '': authorization failed: Could not authenticate to server: rejected Basic challenge (
[ERROR] -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]