Jenkins - Redirect Native UI to Blue Ocean

Redirect the native Jenkins UI to Blue Ocean

目前为 2024-10-31 提交的版本。查看 最新版本

// ==UserScript==
// @name         Jenkins - Redirect Native UI to Blue Ocean
// @namespace    https://greasyfork.org/en/scripts?by=1388261
// @version      1.0
// @description  Redirect the native Jenkins UI to Blue Ocean
// @author       [email protected]
// @match        https://jenkins.audibene.net/job/*/job/*/job/*/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=audibene.net
// @tag          productivity
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const url = window.location.href
    const parameterizedUrl = "https://jenkins.audibene.net/blue/organizations/jenkins/:organizationId%2F:repo/detail/:pr/:run/pipeline/";

    const regex = /https:\/\/jenkins\.audibene\.net\/job\/(?<organizationId>[^\/]+)\/job\/(?<repo>[^\/]+)\/job\/(?<pr>[^\/]+)\/(?<run>[^\/]+)\/pipeline-graph\//;

    const match = url.match(regex);

    if (match) {
        const { organizationId, repo, pr, run } = match.groups;

        const hydratedUrl = parameterizedUrl
        .replace(':organizationId', organizationId)
        .replace(':repo', repo)
        .replace(':pr', pr)
        .replace(':run', run);

        console.log(`Hydrated URL: ${hydratedUrl}`);

        if (confirm('Redirect to Blue Ocean?')) {
            window.location.href = hydratedUrl;
        }
    } else {
        console.log("No match found");
    }
})();