|
1 | 1 | package org.csanchez.jenkins.plugins.kubernetes; |
2 | 2 |
|
3 | 3 |
|
| 4 | +import io.fabric8.kubernetes.client.KubernetesClientBuilder; |
4 | 5 | import java.util.Base64; |
5 | 6 | import java.util.Collections; |
6 | 7 | import java.util.logging.Logger; |
|
18 | 19 |
|
19 | 20 | import io.fabric8.kubernetes.client.Config; |
20 | 21 | import io.fabric8.kubernetes.client.ConfigBuilder; |
21 | | -import io.fabric8.kubernetes.client.DefaultKubernetesClient; |
22 | 22 | import io.fabric8.kubernetes.client.KubernetesClient; |
23 | 23 | import org.jenkinsci.plugins.kubernetes.auth.KubernetesAuth; |
24 | 24 | import org.jenkinsci.plugins.kubernetes.auth.KubernetesAuthConfig; |
@@ -144,7 +144,10 @@ public KubernetesClient createClient() throws KubernetesAuthException { |
144 | 144 | } |
145 | 145 | } |
146 | 146 | } |
147 | | - return new DefaultKubernetesClient(builder.build()); |
| 147 | + // TODO post 2.362 use jenkins.util.SetContextClassLoader |
| 148 | + try (WithContextClassLoader ignored = new WithContextClassLoader(getClass().getClassLoader())) { |
| 149 | + return new KubernetesClientBuilder().withConfig(builder.build()).build(); |
| 150 | + } |
148 | 151 | } |
149 | 152 | private String getProxyPasswordDecrypted(ProxyConfiguration p) { |
150 | 153 | String passwordEncrypted = p.getPassword(); |
@@ -184,4 +187,19 @@ private static StandardCredentials resolveCredentials(@CheckForNull String crede |
184 | 187 | } |
185 | 188 | return c; |
186 | 189 | } |
| 190 | + |
| 191 | + private static class WithContextClassLoader implements AutoCloseable { |
| 192 | + |
| 193 | + private final ClassLoader previousClassLoader; |
| 194 | + |
| 195 | + public WithContextClassLoader(ClassLoader classLoader) { |
| 196 | + this.previousClassLoader = Thread.currentThread().getContextClassLoader(); |
| 197 | + Thread.currentThread().setContextClassLoader(classLoader); |
| 198 | + } |
| 199 | + |
| 200 | + @Override |
| 201 | + public void close() { |
| 202 | + Thread.currentThread().setContextClassLoader(previousClassLoader); |
| 203 | + } |
| 204 | + } |
187 | 205 | } |
0 commit comments