|
14 | 14 | import org.apache.commons.codec.binary.Base64; |
15 | 15 | import org.jenkinsci.main.modules.instance_identity.InstanceIdentity; |
16 | 16 | import org.jenkinsci.plugins.github.GitHubPlugin; |
| 17 | +import org.jenkinsci.plugins.github.Messages; |
17 | 18 | import org.jenkinsci.plugins.github.internal.GHPluginConfigException; |
18 | 19 | import org.jenkinsci.plugins.github.migration.Migrator; |
19 | 20 | import org.kohsuke.github.GitHub; |
|
34 | 35 |
|
35 | 36 | import static com.google.common.base.Charsets.UTF_8; |
36 | 37 | import static java.lang.String.format; |
| 38 | +import static org.apache.commons.lang3.StringUtils.isEmpty; |
37 | 39 | import static org.jenkinsci.plugins.github.config.GitHubServerConfig.allowedToManageHooks; |
38 | 40 | import static org.jenkinsci.plugins.github.config.GitHubServerConfig.loginToGithub; |
39 | 41 | import static org.jenkinsci.plugins.github.util.FluentIterableWrapper.from; |
@@ -103,13 +105,17 @@ public void setOverrideHookUrl(boolean overrideHookUrl) { |
103 | 105 |
|
104 | 106 | public URL getHookUrl() throws GHPluginConfigException { |
105 | 107 | try { |
| 108 | + String jenkinsUrl = Jenkins.getInstance().getRootUrl(); |
| 109 | + |
| 110 | + if (isEmpty(jenkinsUrl)) { |
| 111 | + throw new GHPluginConfigException(Messages.global_config_url_is_empty()); |
| 112 | + } |
| 113 | + |
106 | 114 | return hookUrl != null |
107 | 115 | ? hookUrl |
108 | | - : new URL(Jenkins.getInstance().getRootUrl() + GitHubWebHook.get().getUrlName() + '/'); |
| 116 | + : new URL(jenkinsUrl + GitHubWebHook.get().getUrlName() + '/'); |
109 | 117 | } catch (MalformedURLException e) { |
110 | | - throw new GHPluginConfigException( |
111 | | - "Mailformed GH hook url in global configuration (%s)", e.getMessage() |
112 | | - ); |
| 118 | + throw new GHPluginConfigException(Messages.global_config_hook_url_is_mailformed(e.getMessage())); |
113 | 119 | } |
114 | 120 | } |
115 | 121 |
|
|
0 commit comments