3

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)/

4

2 回答 2

7

这是我用来做的方式:

JenkinsLocationConfiguration globalConfig = new JenkinsLocationConfiguration();
globalConfig.getUrl()
于 2013-04-11T13:55:30.313 回答
3

除了其他答案的JenkinsLocationConfiguration 类Jenkins.getInstance.getRootUrl()返回配置的url。

还要检查Jenkins.getInstance.getRootUrlFromRequest(),它返回正在使用的真实 url,但仅在处理请求时。

于 2013-04-11T19:02:05.153 回答