JENKINS-13726: Github plugin should work with Guthub enterprise by allowing for overriding the github URL.

This commit is contained in:
johnou
2013-01-06 00:47:44 +01:00
committed by Johno Crawford
parent 1ba8f2ccbf
commit 35d45ca47d
2 changed files with 46 additions and 3 deletions

View File

@@ -118,6 +118,10 @@ public class GitHub {
return new GitHub(props.getProperty("login"),props.getProperty("token"),props.getProperty("password"));
}
public static GitHub connect(String githubServer, String login, String apiToken, String password){
return new GitHub(githubServer,login,apiToken,password);
}
public static GitHub connect(String login, String apiToken){
return new GitHub(login,apiToken,null);
}
@@ -153,10 +157,20 @@ public class GitHub {
tailApiUrl = tailApiUrl + (tailApiUrl.indexOf('?')>=0 ?'&':'?') + "access_token=" + oauthAccessToken;
}
if (tailApiUrl.startsWith("/"))
return new URL("https://api."+githubServer+tailApiUrl);
else
if (tailApiUrl.startsWith("/")) {
if ("github.com".equals(githubServer)) {
return new URL("https://api." + githubServer + tailApiUrl);
} else {
// use protocol if defined otherwise default to https.
if (githubServer.matches("^(https?)://.*$")) {
return new URL(githubServer + "/api/v3" + tailApiUrl);
} else {
return new URL("https://" + githubServer + "/api/v3" + tailApiUrl);
}
}
} else {
return new URL(tailApiUrl);
}
}
/*package*/ Requester retrieve() {