View Source

{excerpt}This plugin analyzes the causes of failed builds and presents the causes on the build page. It does this by using a knowledge base of build failure causes that is built up from scratch.
Saving statistics about failure causes is also possible.
{excerpt}
{jenkins-plugin-info:pluginId=build-failure-analyzer}

h3. Knowledge base

The plugin comes with an empty knowledge base of failure causes. Populating this knowledge base is done by using the link "Failure Cause Management".
The link is shown only if the permission UpdateCauses is set for the current user. Press "Create new" and add a name and a description for the Failure Cause.
The description should contain the reason why this build failed as well as possible solutions for the build failure.

One or more optional categories can be added as a whitespace-separated list. These categories are only used for the statistics part of the plugin.
Add one or more Indications by pressing "Add Indication". By default, only one type of Indication exists, a "Build Log Indication".
Plugin developers can add new Indication types and more are planned to be added to the plugin itself.
The Build Log Indication searches through the build log, one line at a time, for a regular expression.
It uses Pattern.match, so the regular expression needs to match the whole line, e.g. .\**some words in the middle of a line.\**
!bfa-newfailurecause.png|border=1!
_Adding new failure causes and indications to the knowledge base._

From version 1.3.1 of the plugin, regular expressions can be tested on the Failure Cause Management page, in two different ways:

* Writing a text in the text field shown above and testing against that.
* Writing a URL to a build log in the text field. The plugin then runs through the log trying to match the regexp.

When accessing the Failure Cause Management page from a build, the URL will be added to the text field automatically.

The plugin comes with two ways of saving the knowledge base:
* Local knowledge base. Saves the knowledge base in memory and serializes it as an xml file on the local Jenkins server (i.e. the "standard" Jenkins way of saving information).
* MongoDB knowledge base. Saves the knowledge base in a Mongo database. This can be used to share the
same knowledge base between servers. The knowledge base is still cached locally in-memory to avoid unnecessary database accesses.
Plugin developers can add new knowledge base types.

h3. Build log scanning

All builds on the server that are non-successful (aborted, failed, unstable) will be scanned for all failure causes. 
If an indication is found, the description will be put directly on the build page, with a link to the matching line in the build log.
If no cause is found, a text stating this will be shown. The text is configurable on the main configuration page of the server.
!bfa-buildpage.PNG|border=1!
_The build page when the build failure analyzer has found a failure cause._



!bfa-buildlog.PNG|border=1!
_The build log with the matching line marked in red._


h3. Statistics

If MongoDB or some knowledge base type that supports statistics is used, statistics will be saved to that database. The same information
that is shown on the build page is saved to the database.

h3. Administrative settings

On the configure system page in Jenkins, under Build failure analyzer, some new settings are available:
* Enabled - since the plugin scans all failed builds, we felt the need to be able to disable the scanning. Uncheck to disable.
* Text when no failure causes are found - text to show for failed builds whose failure cause is not found in the knowledge base.
* Storage type - Jenkins Local or Mongo DB, as described above. For Mongo DB, configuration details to fill in are as follows: Host, Port, Database name, Username and Password for the Database, Enable Statistics logging (described above).
* Convert knowledge base - If this check box is checked when the configuration is saved and a change has been made to the knowledge base settings, the data from the old knowledge base will be added to the new one. Note that duplicates could appear this way, so make sure that you untick this check box if you for example just have changed the username or password, or if you want to start with a clean knowledgebase.
* Send notifications to Gerrit-Trigger-plugin - if enabled, will send the text for the found failure cause via the gerrit-trigger-plugin to Gerrit.
* Concurrent scans - To speed up the scanning, each build will get a threadpool of this number of threads, with each thread handling one indication. For a small system, 3 is usually enough.

h2. Tips & Tricks

h3. Aggregate statistics to Graphite

If you are using the MongoDB KnowledgeBase, you can use these scripts in a cron job to aggregate the statistics into Graphite.

* [Known vs. Unknown Failures per hour|https://gist.github.com/rsandell/9484345]
* [Failure Categories per hour|https://gist.github.com/rsandell/9484534]

h2. Change Log


h4. Version 1.7.0 (released Apr 1, 2014)

* Multi line build log indications
* Optionally store statistics about successful builds


h4. Version 1.6.0 (released Mar 10, 2014)

* Ability to re-scan non scanned builds (for new installations) and all builds for a project
* Graphs on projects, slaves and master(s) if using a statistics logging enabled knowledge base (like the MongoDB Knowledge base)
* Shows failure causes from downstream builds directly on the upstream build page.
* ListView column showing the failure cause of the last build, if there is one.


h4. Version 1.5.1 (released Nov 19, 2013)

* Fixed an XSS vulnerability


h4. Version 1.5.0 (released Apr 24, 2013)


h5. New Features

* The found failure cause is exposed to the REST Api (jobX/1/api).


h4. Version 1.4.1 (released Mar 14, 2013)


h5. Bugs fixed

* [JENKINS-16868|https://issues.jenkins-ci.org/browse/JENKINS-16868] Icons are not displayed with a reverse proxy


h4. Version 1.4.0 (released Feb 15, 2013)


h5. New Features

* Possibility to test regexps on a build log

h5. Bugs fixed

* Log annotation bugfixes.
* [JENKINS-15948|https://issues.jenkins-ci.org/browse/JENKINS-15948] Build Failure Analyzer icons aren't displayed if Jenkins isn't installed at root context.(again)
* [JENKINS-15926|https://issues.jenkins-ci.org/browse/JENKINS-15926] Build Failure Analyzer with Timestamper output ugly.(again)
* [JENKINS-16596|https://issues.jenkins-ci.org/browse/JENKINS-16596] Repeat/double loggin issue due to Build failure Analyzer.
* [JENKINS-16104|https://issues.jenkins-ci.org/browse/JENKINS-16104] Build Failure Analyzer: Ugly output from plugin.
* NPE fix when a slave is taken offline during a build.
* Fix for internal serialization of matrix aggregated indications.
* Small UI fix in failure cause management page.

h4. Version 1.3.0 (released Dec 06, 2012)


h5. New Features

* Possibility to test regexp on a line of text when editing BuildLogIndications
* Output from Build Failure Analyzer shown in normal console.

h5. Bugs fixed

* [JENKINS-15986|https://issues.jenkins-ci.org/browse/JENKINS-15986] Cannot save job configuration pages on Jenkins 1.463 or newer.
* [JENKINS-15948|https://issues.jenkins-ci.org/browse/JENKINS-15948] Build Failure Analyzer icons aren't displayed if Jenkins isn't installed at root context.
* [JENKINS-15926|https://issues.jenkins-ci.org/browse/JENKINS-15926] Build Failure Analyzer with Timestamper output ugly.

h5. Other

* Updated Gerrit Trigger optional dependency: 2.7.0

h4. Version 1.2.0 (released Nov 22, 2012)

Initial Release

h5. Known issues

*Breaks Job configuration pages on Jenkins 1.463 or newer*
The problem we have seen is when loading configuration pages. We don't have a registered descriptor for our notifier,
hence, when the hetero-list for the post build actions is generated, an Exception is thrown.

h2.