From e498785d940fb3fdffc350b6b09607d5e8051b21 Mon Sep 17 00:00:00 2001 From: Michael Brandt Date: Thu, 12 Feb 2015 15:02:09 -0700 Subject: Use JenkinsLocationConfiguration to fetch the URL. `Jenkins.getInstance().getRootUrl()` returns `null` despite the URL being set through the web UI. `JenkinsLocationConfiguration.getUrl()` returns the correct URL. Thanks Esteban Angee on StackOverflow: http://stackoverflow.com/questions/15949946/programatically-access-jenkins-url [Resolves #19] --- .../bitbucketpullrequestbuilder/BitbucketBuilds.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuilds.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuilds.java index 3e8e84b..ea8e892 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuilds.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuilds.java @@ -5,6 +5,7 @@ import hudson.model.AbstractBuild; import hudson.model.Cause; import hudson.model.Result; import jenkins.model.Jenkins; +import jenkins.model.JenkinsLocationConfiguration; import java.io.IOException; import java.util.logging.Level; @@ -49,7 +50,8 @@ public class BitbucketBuilds { return; } Result result = build.getResult(); - String rootUrl = Jenkins.getInstance().getRootUrl(); + JenkinsLocationConfiguration globalConfig = new JenkinsLocationConfiguration(); + String rootUrl = globalConfig.getUrl(); String buildUrl = ""; if (rootUrl == null) { logger.warning("PLEASE SET JENKINS ROOT URL IN GLOBAL CONFIGURATION FOR BUILD STATE REPORTING"); -- cgit v1.2.3