NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name JenkinsPipelineSteps // @version 1.12 // @description Add extra table with red steps in the top of the page // @author Magnus HÃ¥kansson // @match *://*/*/job/*/flowGraphTable/ // @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js // @run-at document-end // @grant none // @license MIT // ==/UserScript== function addTable(tableId, status, header) { jQuery('div#main-panel').prepend("<table id=" + tableId + " class='pane bigtable'>"); jQuery('table#' + tableId).append("<tr><th>Agent</th><th>Context</th><th>" + header + "</th><th>Arguments</th><th width='32'>Link</th><th width='32'>Status</th></tr>"); jQuery("[tooltip='" + status + "']").parent().parent().parent().parent().parent().each(function(index, element) { // Ignore some nodes if (jQuery(element).children('td').length < 4) { return; } if (jQuery(element).find('a:contains("Start of Pipeline - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Stage : Start - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Timestamps : Start - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Timestamps : Body : Start - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Enforce time limit : Start - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Enforce time limit : Body : Start - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Execute in parallel : Start - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Execution - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Branch: Sense ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Set environment variables : ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Sets up Docker registry endpoint : ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Sets up Docker registry endpoint : ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Run build steps inside a Docker container : ")').size() == 1) { return; } if (jQuery(element.firstChild).find('a:contains("Branch: ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Allocate node : ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Allocate workspace : ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Branch: Run")').size() == 1) { return; } if (jQuery(element).find('a:contains("withCredentials - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("withEnv - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("withDockerRegistry")').size() == 1) { return; } if (jQuery(element).find('a:contains("withDockerContainer")').size() == 1) { return; } if (jQuery(element).find('a:contains("withNPM")').size() == 1) { return; } if (jQuery(element).find('a:contains("node - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("node block - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("ws - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("ws block - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("parallel - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("stage - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("stage block ")').size() == 1) { return; } if (jQuery(element).find('a:contains("timestamps - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("timestamps block - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("timeout - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("timeout block - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("Bind credentials to variables")').size() == 1) { return; } if (jQuery(element).find('a:contains("Publishing - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("SSH Agent : Start - ")').size() == 1) { return; } if (jQuery(element).find('a:contains("SSH Agent : Body : Start - ")').size() == 1) { return; } var clone = element.cloneNode(true); if (jQuery(clone).children('td').length > 4) { jQuery(clone).children('td').eq(2).remove(); } jQuery(clone).find('td:first').removeAttr('style'); var column = document.createElement("td"); var prevAll = jQuery(element).prevAll(); var branch = prevAll.find('a:contains("Branch:")').last(); column.textContent = branch.text(); clone.prepend(column); var allocateNode = branch.parent().parent().next(); var allocateNodeLogUrl = allocateNode.find('a:last').attr("href"); var argumentNodeText = allocateNode.find('td:first').next().text(); jQuery.get(allocateNodeLogUrl, function(data) { var agent = data.match(/Running\son.+>(.+)</)[1]; column = document.createElement("td"); var a = document.createElement("a"); a.textContent = agent + ' (' + argumentNodeText + ')'; column.prepend(a); a.setAttribute('href', '/computer/' + agent); clone.prepend(column); }); jQuery('table#' + tableId).append(clone); }); jQuery('div#' + tableId).insertAfter("</table>"); } function removeRow(searchString) { jQuery('a:contains("' + searchString + '")').parent().parent().each(function (index, element) { element.parentNode.removeChild(element); }); } jQuery(document).ready(function(){ jQuery.noConflict(); addTable('Aborted', 'Aborted', 'Aborted Steps'); addTable('Failed', 'Failed', 'Failed Steps'); addTable('Executing', 'In progress', 'Executing Steps'); removeRow('Determine current directory'); removeRow('Unix-like'); removeRow('Bind credentials to variables : Start'); removeRow('Bind credentials to variables : Body : Start'); removeRow('Set environment variables : Start'); removeRow('Set environment variables : Body : Start'); removeRow('Sets up Docker registry endpoint : Start'); removeRow('Sets up Docker registry endpoint : Body : Start'); removeRow('Allocate node : Body : Start'); removeRow('Allocate workspace : Body : Start'); removeRow('withCredentials - '); removeRow('withCredentials block - '); removeRow('withDockerRegistry - '); removeRow('withDockerRegistry block - '); // removeRow('withDockerContainer - '); This one is wanted removeRow('withDockerContainer block - '); removeRow('withEnv - '); removeRow('withEnv block - '); removeRow('timeout block - '); removeRow('node block - '); removeRow('ws block - '); removeRow('parallel - '); removeRow('pwd - '); });