You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改Jenkins Blue Ocean在GitHub显示的DisplayURLProvider链接?

Hey there, let's tackle that annoying unconfigured Jenkins URL issue you're seeing in GitHub. The root cause here is almost always that Jenkins doesn't have its base URL properly set at the system level—this is exactly what the Display URL API Plugin relies on to generate valid, usable links. Let's break down the two ways to fix this, starting with the global system setup (the recommended approach) and then covering per-pipeline customization if you need it.

1. Fix via Jenkins System Settings (Global, Universal Solution)

This is the most straightforward fix, and it'll apply to all your pipelines automatically. Here's how to do it:

  • Log into your Jenkins instance
  • Navigate to Manage Jenkins > Configure System (the exact label might vary slightly depending on your Jenkins version)
  • Scroll down to the Jenkins Location section
  • In the Jenkins URL field, enter your actual Jenkins server's full URL (e.g., https://jenkins.yourcompany.com or http://your-server-ip:8080)
  • Save your changes

Once saved, kick off a new build for your PR-180 pipeline. The Display URL API Plugin will now use this configured base URL to generate proper links instead of showing unconfigured-jenkins-location.

2. Customize in Jenkinsfile (Per-Pipeline Override)

If you need to override the global URL for a specific pipeline (say, for testing environments or multi-instance setups), you can tweak this directly in your declarative pipeline:

Option A: Override the base URL via environment variables

Define the JENKINS_URL environment variable in your pipeline—this will be picked up by the Display URL API Plugin:

pipeline {
    agent any
    environment {
        // Replace with your target URL for this specific pipeline
        JENKINS_URL = 'https://jenkins.yourcompany.com'
    }
    stages {
        stage('Build') {
            steps {
                echo "Generated Build URL: ${BUILD_URL}"
                echo "Display URL for GitHub: ${DISPLAY_URL}"
            }
        }
    }
}

Option B: Explicitly set a custom display URL

If you need full control over a specific link (rather than just the base URL), you can use the displayUrl step provided by the plugin:

pipeline {
    agent any
    stages {
        stage('Set Custom Display URL') {
            steps {
                script {
                    def customPipelineUrl = "https://jenkins.yourcompany.com/job/CRM/job/PR-180/${BUILD_NUMBER}/display/redirect"
                    displayUrl name: 'Pipeline View', url: customPipelineUrl
                }
            }
        }
    }
}

A quick note: The global system setting is still the best practice—it ensures consistency across all your pipelines. Only use the Jenkinsfile override if you have a specific, justified need for per-pipeline URL differences.

内容的提问来源于stack exchange,提问作者Daniel Khoroshko

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:35:09