Skip to content

Instantly share code, notes, and snippets.

@maxmarkus
Last active February 2, 2018 07:53
Show Gist options
  • Save maxmarkus/0ce8fd8395878a9f8fb1f00a406e8544 to your computer and use it in GitHub Desktop.
Save maxmarkus/0ce8fd8395878a9f8fb1f00a406e8544 to your computer and use it in GitHub Desktop.
Displays errors on top of the console page of a failed job.
// ==UserScript==
// @name Jenkins show deployment errors
// @namespace https://jenkins
// @version 0.2
// @description Displays errors on top of the console page of a failed job.
// @author Markus Edenhauser
// @include /^https://jenkins*/
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==
(function() {
var consoleOutput = jQuery('pre.console-output').html();
if(!consoleOutput) { return; }
console.log('TM: ShowConsoleErrors');
window.consoleOutput = consoleOutput;
var consoleArr = consoleOutput.split(/\r\n|\r|\n/);
var consoleErrors = consoleArr.filter(function(line, index) { return line.toLowerCase().startsWith('error'); });
if(consoleErrors.length) {
var errId = 'my-custom-console-errors';
jQuery('#page-head').append('<div id="'+errId+'"></div><style>#'+errId+' { padding: 5px; background-color: orange; }');
jQuery('#' + errId).append(consoleErrors.join('<br>'));
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment