Permalink
Browse files

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

  • Loading branch information...
recena committed Apr 18, 2016
1 parent af04b02 commit 58db4cc1545ad5cf4e968f3513d218b5ce22e0f4
@@ -51,8 +51,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>github-api</artifactId>
<!-- Update when 1.75 is released -->
<version>1.75-SNAPSHOT</version>
<version>1.72.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -31,7 +31,6 @@
import hudson.model.Descriptor;
import hudson.util.FormValidation;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -116,28 +115,14 @@ public FormValidation doCheckApiUri(@QueryParameter String apiUri) {
URL api = new URL(apiUri);
GitHub github = GitHub.connectToEnterpriseAnonymously(api.toString());
github.checkApiUrlValidity();
LOGGER.log(Level.FINE, "Trying to configure a GitHub Enterprise server");
// For example: https://api.github.com/ or https://github.mycompany.com/api/v3/ (with private mode disabled).
return FormValidation.ok("GitHub Enterprise server verified");
return FormValidation.ok();
} catch (MalformedURLException mue) {
// For example: https:/api.github.com
LOGGER.log(Level.WARNING, "Trying to configure a GitHub Enterprise server: " + apiUri, mue.getCause());
return FormValidation.error("The endpoint does not look like a GitHub Enterprise (malformed URL)");
return FormValidation.error("This does not look like a GitHub Enterprise API URL");
} catch (JsonParseException jpe) {
LOGGER.log(Level.WARNING, "Trying to configure a GitHub Enterprise server: " + apiUri, jpe.getCause());
return FormValidation.error("The endpoint does not look like a GitHub Enterprise (invalid JSON response)");
} 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("The endpoint does not look like a GitHub Enterprise (page not found");
return FormValidation.error("This does not look like a GitHub Enterprise API URL");
} 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, e.getMessage());
return FormValidation.warning("Private mode enabled, validation disabled");
}
LOGGER.log(Level.WARNING, e.getMessage());
return FormValidation.error("The endpoint does not look like a GitHub Enterprise (verify network and/or try again later)");
return FormValidation.error("This does not look like a GitHub Enterprise API URL");
}
}

@@ -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 58db4cc

Please sign in to comment.