diff options
author | Michael Brandt <mbrandt@colorado.edu> | 2015-02-12 15:02:09 -0700 |
---|---|---|
committer | Michael Brandt <mbrandt@colorado.edu> | 2016-04-25 14:23:42 -0600 |
commit | e498785d940fb3fdffc350b6b09607d5e8051b21 (patch) | |
tree | cc1563c4f041a6cf71ddd6b0b4a93e586a5a3fa6 /src/main/java/bitbucketpullrequestbuilder | |
parent | f08fe64257973cddea7ca3ae837f5cfe3db7b720 (diff) | |
download | bbprb-e498785d940fb3fdffc350b6b09607d5e8051b21.tar.gz |
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]
Diffstat (limited to 'src/main/java/bitbucketpullrequestbuilder')
-rw-r--r-- | src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuilds.java | 4 |
1 files changed, 3 insertions, 1 deletions
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"); |