Skip to content

Commit 2b229e5

Browse files
jimklimovJakub Bocheński
authored andcommitted
Just use JenkinsLocationConfiguration.get() per recommendations
1 parent ee35b3f commit 2b229e5

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

src/main/java/stashpullrequestbuilder/stashpullrequestbuilder/StashBuilds.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,11 @@ public void onCompleted(AbstractBuild build, TaskListener listener) {
4949
return;
5050
}
5151
Result result = build.getResult();
52-
JenkinsLocationConfiguration globalConfig = new JenkinsLocationConfiguration();
52+
// Note: current code should no longer use "new JenkinsLocationConfiguration()"
53+
// as only one instance per runtime is really supported by the current core.
54+
JenkinsLocationConfiguration globalConfig = JenkinsLocationConfiguration.get();
5355
String rootUrl = globalConfig.getUrl();
5456
String buildUrl = "";
55-
if (rootUrl == null) {
56-
// Get hold of the currently active config, if this version
57-
// of Jenkins core returns an empty one as new()
58-
try {
59-
globalConfig.load();
60-
rootUrl = globalConfig.getUrl();
61-
} catch (Exception e) {}
62-
}
63-
if (rootUrl == null) {
64-
// Another method to try getting the active config...
65-
try {
66-
globalConfig = JenkinsLocationConfiguration.get();
67-
rootUrl = globalConfig.getUrl();
68-
} catch (Exception e) {}
69-
}
7057
if (rootUrl == null) {
7158
buildUrl = " PLEASE SET JENKINS ROOT URL FROM GLOBAL CONFIGURATION " + build.getUrl();
7259
}

0 commit comments

Comments
 (0)