github-api
github-api copied to clipboard
enterprise apiUrl
org.kohsuke.github.GitHubBuilder#fromProperties()
as well as org.kohsuke.github.GitHubBuilder#fromEnvironment()
doesn't support custom apiUrl
Shouldn't fromEnvironment()
work if you set the environment variable GITHUB_ENDPOINT
? See the code.
Alternatively, you can manually call the method withEndpoint(String)
.
GithubBuilder builder = new GithubBuilder();
builder.withEndpoint(<your-api-url>);
@bmuschko
The fromEnvironment()
builds the GitHub
object in one call it doesn't return a builder. So withEndpoint(String)
can't be used.
But good catch about GITHUB_ENDPOINT
. I didn't even go looking. Do you think we need a change to some documentation or is this just closable?
Shouldn't
fromEnvironment()
work if you set the environment variableGITHUB_ENDPOINT
? See the code.Alternatively, you can manually call the method
withEndpoint(String)
.GithubBuilder builder = new GithubBuilder(); builder.withEndpoint(<your-api-url>);
No it doesn't work this way, the url is hardcoded, so whatever url you set in env won't be picked and default hardcoded value is used
No it doesn't work this way, the url is hardcoded
I guess you are exclusively referring to the environment variable. I use withEndpoint
in a code base so I know that works. I understand it's less convenient.
But good catch about GITHUB_ENDPOINT. I didn't even go looking. Do you think we need a change to some documentation or is this just closable?
- Write a test case (if it doesn't exist yet) for
fromEnvironment
to ensure that reading all supported environment variables are picked up properly. @dimmonn Contributing a test case would be a good way forward. - I think the Javadocs are good enough for documenting the supported environment variables.
@dimmonn
No it doesn't work this way, the url is hardcoded, so whatever url you set in env won't be picked and default hardcoded value is used
This should load the value or default to the hard coded one.
https://github.com/hub4j/github-api/blob/85c44b352958bf6d81b74ab8b21920f1d313a287/src/main/java/org/kohsuke/github/GitHubBuilder.java#L221
But really, as @bmuschko says, tests need to be updated for this.
They are found here:
https://github.com/hub4j/github-api/blob/85c44b352958bf6d81b74ab8b21920f1d313a287/src/test/java/org/kohsuke/github/GitHubConnectionTest.java#L55-L93
As a side note, the fromEnvironment()
and fromEnvironment(String,,,,,)
methods follow independent code paths and have significantly different JavaDocs. Also, we're missing a fromEnvironment(String,,,,,)
that includes JWT
. This area could use some love.
https://github.com/hub4j/github-api/blob/85c44b352958bf6d81b74ab8b21920f1d313a287/src/main/java/org/kohsuke/github/GitHubBuilder.java#L108-L172
@dimmonn - would you be willing to submit a PR for this?
@dimmonn - would you be willing to submit a PR for this?
ill check once will get some time, thanks for info