Jenkins - Redirect Native UI to Blue Ocean

Redirect the native Jenkins UI to Blue Ocean

当前为 2024-10-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Jenkins - Redirect Native UI to Blue Ocean
  3. // @namespace http://hear.com
  4. // @version 2024-07-11
  5. // @description Redirect the native Jenkins UI to Blue Ocean
  6. // @author nate.clark@hear.com
  7. // @match https://jenkins.audibene.net/job/Audibene-GMBH/job/*/job/*/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=audibene.net
  9. // @tag productivity
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const url = window.location.href
  17. const parameterizedUrl = "https://jenkins.audibene.net/blue/organizations/jenkins/:organizationId%2F:repo/detail/:pr/:run/pipeline/";
  18.  
  19. const regex = /https:\/\/jenkins\.audibene\.net\/job\/(?<organizationId>[^\/]+)\/job\/(?<repo>[^\/]+)\/job\/(?<pr>[^\/]+)\/(?<run>[^\/]+)\/pipeline-graph\//;
  20.  
  21. const match = url.match(regex);
  22.  
  23. if (match) {
  24. const { organizationId, repo, pr, run } = match.groups;
  25.  
  26. const hydratedUrl = parameterizedUrl
  27. .replace(':organizationId', organizationId)
  28. .replace(':repo', repo)
  29. .replace(':pr', pr)
  30. .replace(':run', run);
  31.  
  32. console.log(`Hydrated URL: ${hydratedUrl}`);
  33.  
  34. if (confirm('Redirect to Blue Ocean?')) {
  35. window.location.href = hydratedUrl;
  36. }
  37. } else {
  38. console.log("No match found");
  39. }
  40. })();