Skip to content
Permalink
Browse files

[JENKINS-33318] GHE server validation with private mode enabled

  • Loading branch information
recena committed Mar 5, 2016
1 parent e378438 commit fad71a54a45c28b8daacc3e336ff5eaa6a8a6a5b
@@ -48,9 +48,10 @@
</exclusions>
</dependency>
<dependency>
<!-- Update when 1.74 is released -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>github-api</artifactId>
<version>1.71</version>
<version>1.74-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -115,14 +115,23 @@ public FormValidation doCheckApiUri(@QueryParameter String apiUri) {
URL api = new URL(apiUri);
GitHub github = GitHub.connectToEnterpriseAnonymously(api.toString());
github.checkApiUrlValidity();
return FormValidation.ok();
LOGGER.log(Level.FINE, "Trying to configure a GitHub Enterprise server");
return FormValidation.ok("GitHub Enterprise server verified");
} catch (MalformedURLException mue) {
return FormValidation.error("This does not look like a GitHub Enterprise API URL");
// For example: https:/api.github.com
LOGGER.log(Level.WARNING, "Trying to configure a GitHub Enterprise server: " + apiUri);
return FormValidation.error("This does not look like a GitHub Enterprise API endpoint");
} catch (JsonParseException jpe) {
return FormValidation.error("This does not look like a GitHub Enterprise API URL");
LOGGER.log(Level.WARNING, "Trying to configure a GitHub Enterprise server: " + apiUri);
return FormValidation.error("This does not look like a GitHub Enterprise API endpoint");
} catch (IOException e) {
if (e.getMessage().contains("private mode enabled")) {
LOGGER.log(Level.FINE, "Trying to configure a GitHub Enterprise server with private mode enabled");
return FormValidation.ok("GitHub Enterprise server verified");
}
// For example: https://github.mycompany.com/api gets a FileNotFoundException
LOGGER.log(Level.WARNING, e.getMessage());
return FormValidation.error("This does not look like a GitHub Enterprise API URL");
return FormValidation.error("This does not look like a GitHub Enterprise API endpoint");
}
}

@@ -417,7 +417,6 @@ public FormValidation doCheckScanCredentialsId(@AncestorInPath SCMSourceOwner co
return FormValidation.error("Invalid credentials");
}
} catch (IOException e) {
// ignore, never thrown
LOGGER.log(Level.WARNING, "Exception validating credentials " + CredentialsNameProvider.name(credentials) + " on " + apiUri);
return FormValidation.error("Exception validating credentials");
}
@@ -1,3 +1,3 @@
<p>
<a href="https://developer.github.com/v3/">GitHub API</a> endpoint such as <code>https://github.example.com/api/v3</code>.
<a href="https://developer.github.com/v3/">GitHub API</a> endpoint such as <code>https://github.example.com/api/v3/</code>.
</p>

0 comments on commit fad71a5

Please sign in to comment.
You can’t perform that action at this time.