Source:
<code>public FormValidation doTestConnection(@QueryParameter String name, @QueryParameter String serverUrl, @QueryParameter String credentialsId, @QueryParameter String serverCertificate, @QueryParameter boolean skipTlsVerify, @QueryParameter String namespace, @QueryParameter int connectionTimeout, @QueryParameter int readTimeout) throws Exception { if (StringUtils.isBlank(name)) return FormValidation.error("name is required"); try { KubernetesClient client = new KubernetesFactoryAdapter(serverUrl, namespace, Util.fixEmpty(serverCertificate), Util.fixEmpty(credentialsId), skipTlsVerify, connectionTimeout, readTimeout).createClient(); client.pods().list(); Pod pod = client.pods().create(new PodBuilder() .withNewMetadata().withGenerateName("kubernetes-plugin-").endMetadata() .withNewSpec() .withContainers( <START> new ContainerBuilder().withName("alpine").withImage("alpine").withCommand("cat") <END> .withTty(true).build()) .endSpec().build()); String podName = pod.getMetadata().getName(); LOGGER.log(Level.FINE, "Created test pod: {0}/{1}", new String[] { pod.getMetadata().getNamespace(), podName }); client.pods().withName(podName).waitUntilReady(30, TimeUnit.SECONDS); client.pods().withName(podName).delete(); return FormValidation.ok("Connection test successful"); } catch (KubernetesClientException e) { LOGGER.log(Level.FINE, String.format("Error testing connection %s", serverUrl), e); return FormValidation.error("Error testing connection %s: %s", serverUrl, e.getCause() == null ? e.getMessage() : String.format("%s: %s", e.getCause().getClass().getName(), e.getCause().getMessage())); } catch (Exception e) { LOGGER.log(Level.FINE, String.format("Error testing connection %s", serverUrl), e); return FormValidation.error("Error testing connection %s: %s", serverUrl, e.getMessage()); } }</code><technical_language>This fail if "alpine" image is available. Jenkins running in a closed build environment access dockerhub, a private registry custom images. happen in enterprise setting.</technical_language>

Target:
public FormValidation doTestConnection(@QueryParameter String name, @QueryParameter String serverUrl, @QueryParameter String credentialsId, @QueryParameter String serverCertificate, @QueryParameter boolean skipTlsVerify, @QueryParameter String namespace, @QueryParameter int connectionTimeout, @QueryParameter int readTimeout) throws Exception { if (StringUtils.isBlank(name)) return FormValidation.error("name is required"); try { KubernetesClient client = new KubernetesFactoryAdapter(serverUrl, namespace, Util.fixEmpty(serverCertificate), Util.fixEmpty(credentialsId), skipTlsVerify, connectionTimeout, readTimeout).createClient(); client.pods().list(); return FormValidation.ok("Connection test successful"); } catch (KubernetesClientException e) { LOGGER.log(Level.FINE, String.format("Error testing connection %s", serverUrl), e); return FormValidation.error("Error testing connection %s: %s", serverUrl, e.getCause() == null ? e.getMessage() : String.format("%s: %s", e.getCause().getClass().getName(), e.getCause().getMessage())); } catch (Exception e) { LOGGER.log(Level.FINE, String.format("Error testing connection %s", serverUrl), e); return FormValidation.error("Error testing connection %s: %s", serverUrl, e.getMessage()); } }