How can I programmatically access Jenkins URL field that is configured through Manage Jenkins > Configure System > Jenkins Location?
I tried Computer.currentComputer().getUrl()
but returns only computer/(master)/
How can I programmatically access Jenkins URL field that is configured through Manage Jenkins > Configure System > Jenkins Location?
I tried Computer.currentComputer().getUrl()
but returns only computer/(master)/
这是我用来做的方式:
JenkinsLocationConfiguration globalConfig = new JenkinsLocationConfiguration();
globalConfig.getUrl()
除了其他答案的JenkinsLocationConfiguration 类,Jenkins.getInstance.getRootUrl()返回配置的url。
还要检查Jenkins.getInstance.getRootUrlFromRequest(),它返回正在使用的真实 url,但仅在处理请求时。