Skip to content

Commit ee35b3f

Browse files
jimklimovJakub Bocheński
authored andcommitted
StashBuilds.java : first try to load() the global config into our object... and do try/catch for cores that do not have this API
1 parent 422eab9 commit ee35b3f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,17 @@ public void onCompleted(AbstractBuild build, TaskListener listener) {
5555
if (rootUrl == null) {
5656
// Get hold of the currently active config, if this version
5757
// of Jenkins core returns an empty one as new()
58-
globalConfig = JenkinsLocationConfiguration.get();
59-
rootUrl = globalConfig.getUrl();
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) {}
6069
}
6170
if (rootUrl == null) {
6271
buildUrl = " PLEASE SET JENKINS ROOT URL FROM GLOBAL CONFIGURATION " + build.getUrl();

0 commit comments

Comments
 (0)