Jenkins Config XML File Viewer

Add a link to view the job's XML configuration file from the job's page. This link is titled "View Config XML File."

  1. // ==UserScript==
  2. // @name Jenkins Config XML File Viewer
  3. // @namespace http://budw.in/
  4. // @version 0.2
  5. // @description Add a link to view the job's XML configuration file from the job's page. This link is titled "View Config XML File."
  6. // @author Drew Budwin
  7. // @match http*://*/job/*
  8. // @require https://code.jquery.com/jquery-2.2.1.js
  9. // @require https://gf.qytechs.cn/scripts/6250-waitforkeyelements/code/waitForKeyElements.js?version=23756
  10. // ==/UserScript==
  11. /* jshint -W097 */
  12. /* globals $:false */
  13. /* global waitForKeyElements */
  14. 'use strict';
  15.  
  16. waitForKeyElements(".icon-folder.icon-xlg", addConfigXMLFileLinkWithImage);
  17.  
  18. function addConfigXMLFileLinkWithImage()
  19. {
  20. $('table').each(function()
  21. {
  22. var tableToPrependRowTo = $(this);
  23. if (tableToPrependRowTo.children().is(':contains("Workspace")'))
  24. {
  25. var rowToPrepend = getRowWithLinkAndImage();
  26. tableToPrependRowTo.prepend(rowToPrepend);
  27. }
  28. });
  29. }
  30.  
  31. function getRowWithLinkAndImage()
  32. {
  33. return '<tr><td>' + getConfigXMLFileLinkWithImage() + '</td><td style="vertical-align:middle">' + getConfigXMLFileLink() + '</td></tr>';
  34. }
  35.  
  36. function getConfigXMLFileLinkWithImage()
  37. {
  38. return '<a href="' + getConfigXMLFileUrl() + '"><img src="' + getSettingIconUrl() + '"></a>';
  39. }
  40.  
  41. function getConfigXMLFileLink()
  42. {
  43. return '<a href="' + getConfigXMLFileUrl() + '">View Config XML File</a>';
  44. }
  45.  
  46. function getConfigXMLFileUrl()
  47. {
  48. return window.location.href + 'config.xml';
  49. }
  50.  
  51. function getSettingIconUrl()
  52. {
  53. var baseUrl = window.location.protocol + '//' + window.location.host;
  54. var resourceLocation = $('head').attr('resURL') + '/';
  55. var settingsIconName = 'images/48x48/setting.png';
  56. var imageUrl = baseUrl + resourceLocation + settingsIconName;
  57. return imageUrl;
  58. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址