mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-05 08:21:21 +00:00
Modify GitHubBuilder to resolve user credentials from the system environment
Using the Jenkins EnvInject or Credentials Binding Plugins its possible to pass credentials as Environment Variables. Its useful for Github.connect() to be able to directly read the values of the 'login', 'password' and 'oauth' properties directly from the environment. This commit modifies the base Github.connect() method to resolve credentials in two steps: 1. ~/.github credentials file if it exists. 2. login, password or oauth variables from the environment A further fromEnvironment() method is provided to support loading from non-standard variable names. The old Github.connect() method would throw an IOException if the ~/.github file did not exist. Now it will fail silently instead dropping back to the anonymous users access level. Added new unit tests into GitHubTest.
This commit is contained in:
@@ -128,10 +128,10 @@ public class GitHub {
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the credential from "~/.github"
|
||||
* Obtains the credential from "~/.github" or from the System Environment Properties.
|
||||
*/
|
||||
public static GitHub connect() throws IOException {
|
||||
return GitHubBuilder.fromPropertyFile().build();
|
||||
return GitHubBuilder.fromCredentials().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user