The Mystery of the Failed Jenkins Build

By | September 2, 2013
Reading Time: 4 minutes

Lately, I have had the opportunity to set up a Jenkins (http://jenkins-ci.org/) build server and the associated software as well as migrating Jenkins jobs from an old server.
In this process I encountered builds that failed for some mysterious reason that I weren’t able to determine from the console log of the build supplied by Jenkins.
The log below originates from an attempt to perform a Maven release with Jenkins.

[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - Scanning for projects...
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - Scanning for projects...
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener -
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - ------------------------------------------------------------------------
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - Building MyProduct 1.0.1
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - ------------------------------------------------------------------------
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - Building MyProduct 1.0.1
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener -
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - --- maven-release-plugin:2.4.1:prepare (default-cli) @ my-product ---
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger -
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - --- maven-release-plugin:2.4.1:prepare (default-cli) @ my-product ---
[TASKS] Scanning folder '/home/ivan/.jenkins/jobs/my-product/workspace' for files matching the pattern '**/*.java' - excludes:
[TASKS] Found 21 files to scan for tasks
Found 0 open tasks.
[TASKS] Computing warning deltas based on reference build #40
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - ------------------------------------------------------------------------
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - BUILD FAILURE
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - ------------------------------------------------------------------------
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - Total time: 5.675s
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - Finished at: Mon Aug 19 19:42:15 CEST 2013
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - Final Memory: 14M/247M
[pool-1-thread-2] INFO hudson.maven.Maven3Builder$MavenExecutionListener - ------------------------------------------------------------------------
[JENKINS] Archiving /home/ivan/.jenkins/jobs/my-product/workspace/pom.xml to /home/ivan/.jenkins/jobs/my-product/...
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - BUILD FAILURE
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - Total time: 6.463s
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - Finished at: Mon Aug 19 19:42:16 CEST 2013
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - Final Memory: 15M/247M
[pool-1-thread-2] INFO org.apache.maven.cli.event.ExecutionEventLogger - ------------------------------------------------------------------------
channel stopped
Skipping Cobertura coverage report as build was not UNSTABLE or better ...
Finished: FAILURE

It looks like everything is going well until suddenly there is a build failure.

Locating the Workspace

After some time I came to think of the idea to try to perform the Maven release from the Jenkins server.
To do this, I first had to locate the workspace of my Jenkins job – the one that can be viewed from within Jenkins in the following view:

Jenkins Workspace

On the server which Jenkins is deployed, the default Jenkins home directory is a directory with the name “.jenkins” in the home directory of the user which run Jenkins.
In the Jenkins home directory, there is a “jobs” directory in which there will be one directory for each job. If I log into the Jenkins server and change directory to the directory of the failing job, there will be the following files and directories (variations may occur):

drwxrwxr-x 6 ivan ivan 4096 aug 29 19:36 .
drwxr-xr-x 130 ivan ivan 12288 aug 15 18:57 ..
drwxr-xr-x 7 ivan ivan 4096 aug 29 19:36 builds
drwxrwxr-x 3 ivan ivan 4096 aug 14 18:11 cobertura
-rw-r--r-- 1 ivan ivan 12000 aug 29 19:17 config.xml
lrwxrwxrwx 1 ivan ivan 22 aug 29 19:36 lastStable -> builds/lastStableBuild
lrwxrwxrwx 1 ivan ivan 26 aug 29 19:36 lastSuccessful -> builds/lastSuccessfulBuild
-rw-r--r-- 1 ivan ivan 4 aug 29 19:30 nextBuildNumber
-rw-rw-r-- 1 ivan ivan 242 aug 30 19:48 scm-polling.log
-rw-rw-r-- 1 ivan ivan 493 apr 16 18:58 subversion.credentials
-rw-r--r-- 1 ivan ivan 46 aug 29 19:30 svnexternals.txt
drwxr-xr-x 8 ivan ivan 4096 aug 29 19:30 workspace

Going into the “workspace” directory, there are the following files:

drwxr-xr-x 8 ivan ivan 4096 aug 29 1:30 .
drwxrwxr-x 6 ivan ivan 4096 aug 29 19:36 ..
-rw-r--r-- 1 ivan ivan 314 aug 29 19:21 .checkstyle
-rw-r--r-- 1 ivan ivan 1503 aug 29 19:28 pom.xml
drwxr-xr-x 2 ivan ivan 4096 aug 29 19:21 src
drwxr-xr-x 4 ivan ivan 4096 aug 29 19:30 .svn
drwxr-xr-x 3 ivan ivan 4096 aug 29 19:30 target

Here I find a Maven pom.xml file, thus this is the directory I want to be located in when attempting a Maven release.

Attempting a Release

I use the Maven release plugin (http://maven.apache.org/maven-release/maven-release-plugin/index.html) to perform my releases, so in the console I enter the following to prepare for a dry-run of the release:

mvn -DdryRun=true release:prepare

Note that I have on an earlier occasion entered the Subversion credentials needed to connect to my source-code repository.

When Maven is preparing the release, I now see some console output that did not show up in the Jenkins GUI and I am able to determine the cause of the failed build.
If, for some reason, the release preparations do succeed, I continue by attempting a dry-run of the release:

mvn -DdryRun=true release:release

Reasons for Failure

Some of the reasons for a build “mysteriously” failing in Jenkins that I have seen are:

  • Having forgotten to install a Subversion client.
    I use Subversion and, in order for Jenkins to be able to connect to my source-code repository, the “svn” command has to be installed in the Linux environment in which I have deployed Jenkins.
  • A mismatch between the Subversion working copy format version and the working copy format that the “svn” command is able to handle.
    In my case, I had set the working copy format version in Jenkins to a more recent version than the “svn” command were able to handle.
    The solution is either to change the version configured in Jenkins and wipe all workspaces before attempting any builds or to updated the “svn” command.

Leave a Reply

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