Skip to content

Commit

Permalink
[JENKINS-33318] Reviewed
Browse files Browse the repository at this point in the history
  • Loading branch information
recena committed Apr 18, 2016
1 parent fad71a5 commit 0748599
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -31,6 +31,7 @@
import hudson.model.Descriptor;
import hudson.util.FormValidation;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -124,12 +125,16 @@ public FormValidation doCheckApiUri(@QueryParameter String apiUri) {
} catch (JsonParseException jpe) {
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 (FileNotFoundException fnt) {
// For example: https://github.mycompany.com/server/api/v3/ gets a FileNotFoundException
LOGGER.log(Level.WARNING, "Getting HTTP Error 404 for " + apiUri);
return FormValidation.error("This does not look like a GitHub Enterprise API endpoint");
} catch (IOException e) {
// For example: https://github.mycompany.com/api/v3/ or https://github.mycompany.com/api/v3/mypath
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");
LOGGER.log(Level.FINE, e.getMessage());
return FormValidation.warning("Private mode enabled, validation disabled");
}
// 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 endpoint");
}
Expand Down

0 comments on commit 0748599

Please sign in to comment.