{
public final String username;
+ public final String apiUrl;
+ public final String apiToken;
public final Secret password;
@DataBoundConstructor
- public Credential(String username, Secret password) {
+ public Credential(String username, Secret password, String apiUrl, String apiToken) {
this.username = username;
this.password = password;
+ this.apiUrl = apiUrl;
+ this.apiToken = apiToken;
}
public GitHub login() throws IOException {
- return GitHub.connect(username,null,password.getPlainText());
+ if (Util.fixEmpty(apiUrl) != null) {
+ return GitHub.connectToEnterprise(apiUrl,username,apiToken);
+ }
+ return GitHub.connect(username,apiToken,password.getPlainText());
}
@Extension
@@ -37,8 +45,15 @@ public String getDisplayName() {
return ""; // unused
}
- public FormValidation doValidate(@QueryParameter String username, @QueryParameter Secret password) throws IOException {
- if (GitHub.connect(username,null,Secret.toString(password)).isCredentialValid())
+ public FormValidation doValidate(@QueryParameter String apiUrl, @QueryParameter String username, @QueryParameter Secret password, @QueryParameter String apiToken) throws IOException {
+ GitHub gitHub;
+ if (Util.fixEmpty(apiUrl) != null) {
+ gitHub = GitHub.connectToEnterprise(apiUrl,username,apiToken);
+ } else {
+ gitHub = GitHub.connect(username,apiToken,Secret.toString(password));
+ }
+
+ if (gitHub.isCredentialValid())
return FormValidation.ok("Verified");
else
return FormValidation.error("Failed to validate the account");
diff --git a/src/main/java/com/cloudbees/jenkins/GitHubWebHook.java b/src/main/java/com/cloudbees/jenkins/GitHubWebHook.java
index 4dd212161..4bb321c37 100644
--- a/src/main/java/com/cloudbees/jenkins/GitHubWebHook.java
+++ b/src/main/java/com/cloudbees/jenkins/GitHubWebHook.java
@@ -197,9 +197,4 @@ public void processGitHubPayload(String payload, Class extends Trigger>> tri
public static GitHubWebHook get() {
return Hudson.getInstance().getExtensionList(RootAction.class).get(GitHubWebHook.class);
}
-
- static {
- // hide "Bad input type: "search", creating a text input" from createElementNS
- Logger.getLogger(com.gargoylesoftware.htmlunit.html.InputElementFactory.class.getName()).setLevel(WARNING);
- }
}
diff --git a/src/main/resources/com/cloudbees/jenkins/Credential/config.jelly b/src/main/resources/com/cloudbees/jenkins/Credential/config.jelly
index 4af8be6b1..018ed165e 100644
--- a/src/main/resources/com/cloudbees/jenkins/Credential/config.jelly
+++ b/src/main/resources/com/cloudbees/jenkins/Credential/config.jelly
@@ -1,9 +1,15 @@
+
+
+
-
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/com/cloudbees/jenkins/Credential/help-apiUrl.html b/src/main/resources/com/cloudbees/jenkins/Credential/help-apiUrl.html
new file mode 100644
index 000000000..2c2d32f14
--- /dev/null
+++ b/src/main/resources/com/cloudbees/jenkins/Credential/help-apiUrl.html
@@ -0,0 +1,3 @@
+
+ If you use GitHub Enterprise you may specify the API end point here eg. "https://ghe.acme.com/api/v3", the API key is required and password is ignored.
+
diff --git a/src/main/resources/com/cloudbees/jenkins/Credential/help-password.html b/src/main/resources/com/cloudbees/jenkins/Credential/help-password.html
new file mode 100644
index 000000000..a85631712
--- /dev/null
+++ b/src/main/resources/com/cloudbees/jenkins/Credential/help-password.html
@@ -0,0 +1,3 @@
+
+ Password is no longer required if you specify the API key.
+
diff --git a/src/main/resources/com/cloudbees/jenkins/Credential/help-username.html b/src/main/resources/com/cloudbees/jenkins/Credential/help-username.html
index 99da5b4fd..f2d0a57b2 100644
--- a/src/main/resources/com/cloudbees/jenkins/Credential/help-username.html
+++ b/src/main/resources/com/cloudbees/jenkins/Credential/help-username.html
@@ -1,5 +1,3 @@
- Credentials used to access GitHub to install/remove hooks. Because GitHub doesn't have an API for managing
- hooks, we also need to ask you to provide password, in addition to the API key.
If your Jenkins uses multiple repositories that spread across different user accounts, you can list them all here.
\ No newline at end of file