See https://github-api.kohsuke.org/ for more details
hub4j / github-api Goto Github PK
View Code? Open in Web Editor NEWJava API for GitHub
Home Page: https://github-api.kohsuke.org/
License: MIT License
Java API for GitHub
Home Page: https://github-api.kohsuke.org/
License: MIT License
See https://github-api.kohsuke.org/ for more details
And calling GHIssue.getLabels()
returns a list with a lot of pieces of the json text.
Using the following line:
GitHub github = GitHub.connectAnonymously();
Generates:
Exception in thread "main" java.lang.IllegalStateException: This operation requires a credential but none is given to the GitHub constructor
at org.kohsuke.github.GitHub.requireCredential(GitHub.java:197)
at org.kohsuke.github.GitHub.getMyself(GitHub.java:228)
at org.kohsuke.github.GitHub.(GitHub.java:127)
at org.kohsuke.github.GitHub.(GitHub.java:74)
at org.kohsuke.github.GitHub.connectAnonymously(GitHub.java:192)
at com.omertron.githubtest.GitHubTest.(GitHubTest.java:16)
at com.omertron.githubtest.App.main(App.java:8)
Note: I do not have a ".github" file in my user directory (nor do I want one, I just want to be able to access github anon from my code)
When trying to get comments for pull requests with no comments NoSuchElementException
is thrown.
I would except empty list instead.
java.util.NoSuchElementException
at org.kohsuke.github.Requester$1.next(Requester.java:212)
at org.kohsuke.github.PagedIterator.fetch(PagedIterator.java:42)
at org.kohsuke.github.PagedIterator.nextPage(PagedIterator.java:57)
at org.kohsuke.github.PagedIterable.asList(PagedIterable.java:20)
at org.kohsuke.github.GHIssue.getComments(GHIssue.java:184)
API response for /repos/janinko/test/issues/7/comments
with no comments - there are no Link
header and returns empty array:
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 10 Sep 2012 12:11:37 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
Cache-Control: max-age=0, private, must-revalidate
X-Content-Type-Options: nosniff
ETag: "a00049ba79152d03380c34652f2cb612"
Content-Length: 5
X-RateLimit-Limit: 5000
X-GitHub-Media-Type: github.beta
X-RateLimit-Remaining: 4957
[
]
So IMHO in PagedIterable.asList()
i.hasNext()
returns true because it has next (but empty) array.
When attempting to get the details of an empty repository, the github enterprise server returns an HTTP 409. This, in turn, causes Requester to throw an Error…
Caused by: java.io.IOException: Server returned HTTP response code: 409 for URL:
An Error, for those unfamiliar, is "a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch." I don't think an HTTP 409 response warrants throwing an Error, thereby dooming the client Java process to exit with status code 1.
GHRepository doesn't take into account whether or not the client is speaking with the public github.com or if it's talking to a github enterprise instance. Consequently, when you call getGitTransportUrl() or gitHttpTransportUrl() it only ever returns a github.com URL, which won't work for github enterprise hosted repositories.
It should be "[email protected]:kohsuke/github-api.git", it is "[email protected]/kohsuke/github-api.git".
I see this warning during compilation when org.kohsuke:github-api:jar
is in classpath:
[WARNING] Cannot find annotation method 'value()' in type 'com.infradna.tool.bridge_method_injector.WithBridgeMethods': class file for com.infradna.tool.bridge_method_injector.WithBridgeMethods not found
Would be great to get rid of it
I written like below;
GitHub gh = GitHub.connect("YusukeKokubo", "xxx", "xxx");
GHUser user = gh.getMyself();
user.getRepositories();
and got exception
Exception in thread "main" java.io.FileNotFoundException: https://api.github.com/user/YusukeKokubo/repos?per_page=100&page=1
owners are always returned as GHUsers instead of GHOrganizations or GHUsers. Many github api calls return users and organisations alike and the distinction is made based on the type field. Making GHPerson reflect that:
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME,
include=JsonTypeInfo.As.PROPERTY,
property="type")
@JsonSubTypes({
@JsonSubTypes.Type(value=GHUser.class, name="User"),
@JsonSubTypes.Type(value=GHOrganization.class, name="Organization"),
})
public abstract class GHPerson {
will break a lot of owner related githup-api calls
The GitHub status API now supports the concept of optional contexts for commit statuses. It would be useful to be able to add those from the Java API for the benefit of things like the GitHub Pull Request builder.
I'm going to try and find some time in the next week to actually work on this. If someone else starts tackling it before I get around to it, please comment here so we're not duplicating work! :)
I'm using version 1.44 and in the code there's
protected String html_url;
But it doesn't seem to get populated and there's no getter method..
The GitHub API does return it though. For example: api.github.com/users/vmassol
Thanks
You either use this:
/repos/:owner/:repo/readme
Or you just change it to this:
GHContent getReadme(){
return getFileContent("README.md");
}
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching api.github.com found.
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1917)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:301)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:295)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1369)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:156)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:925)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:860)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1043)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1343)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1371)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1355)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1511)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at org.kohsuke.github.Requester.parse(Requester.java:359)
at org.kohsuke.github.Requester._to(Requester.java:180)
at org.kohsuke.github.Requester.to(Requester.java:155)
at org.kohsuke.github.GitHub.getRateLimit(GitHub.java:244)
at org.jenkinsci.plugins.ghprb.GhprbRepository.initGhRepository(GhprbRepository.java:51)
at org.jenkinsci.plugins.ghprb.GhprbRepository.check(GhprbRepository.java:73)
at org.jenkinsci.plugins.ghprb.Ghprb.run(Ghprb.java:95)
at org.jenkinsci.plugins.ghprb.GhprbTrigger.run(GhprbTrigger.java:124)
at hudson.triggers.Trigger.checkTriggers(Trigger.java:266)
at hudson.triggers.Trigger$Cron.doRun(Trigger.java:214)
at hudson.triggers.SafeTimerTask.run(SafeTimerTask.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.security.cert.CertificateException: No subject alternative DNS name matching api.github.com found.
at sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:191)
at sun.security.util.HostnameChecker.match(HostnameChecker.java:93)
at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)
at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1351)
... 30 more
I use Jenkins via HTTPS with self-signed certificate - maybe it's related to
http://stackoverflow.com/questions/10258101/sslhandshakeexception-no-subject-alternative-names-present
or
http://stackoverflow.com/questions/8443081/how-are-ssl-certificate-server-names-resolved-can-i-add-alternative-names-using
?
Hi,
I'm trying to tie in to the "Watching" API (https://developer.github.com/v3/activity/watching/) but I can't find any hook to it.
Is it already implemented but I can't see it? If not, would it be possible to implement it? I'm doing my first project in Java now so I'm not able to contribute just yet :(
Thanks in advance!
Using ghprb plugin, we have discovered that closing pull request is not working:
SEVERE: Couldn't close the pullrequest #10582: '
java.io.FileNotFoundException: https://api.github.com/repos/USER/REPO/issues/10582
As Github API says, pull requests must be accesed in this way:
GET /repos/:owner/:repo/pulls/:number
Using pulls intead of issues.
Would be great if the library would also support Gist API: http://developer.github.com/v3/gists/
I'm not sure if I should report this here or to https://github.com/janinko/ghprb, but exception is thrown in at org.kohsuke.github.GHPerson.populate(GHPerson.java:42)
.
I use GitHub API Plugin 1.55
and GitHub Pull Request Builder 1.12
.
Jul 14, 2014 6:54:53 PM WARNING org.jenkinsci.plugins.ghprb.GhprbPullRequest obtainAuthorEmail
Couldn't obtain author email.
java.lang.NullPointerException
at org.kohsuke.github.GHPerson.populate(GHPerson.java:42)
at org.kohsuke.github.GHPerson.getEmail(GHPerson.java:220)
at org.jenkinsci.plugins.ghprb.GhprbPullRequest.obtainAuthorEmail(GhprbPullRequest.java:266)
at org.jenkinsci.plugins.ghprb.GhprbPullRequest.tryBuild(GhprbPullRequest.java:161)
at org.jenkinsci.plugins.ghprb.GhprbPullRequest.check(GhprbPullRequest.java:106)
at org.jenkinsci.plugins.ghprb.GhprbRepository.onPullRequestHook(GhprbRepository.java:233)
at org.jenkinsci.plugins.ghprb.GhprbRootAction.doIndex(GhprbRootAction.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:298)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:161)
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:96)
at org.kohsuke.stapler.MetaClass$2.dispatch(MetaClass.java:164)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:728)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:858)
at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:390)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:728)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:858)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:631)
(...)
When attempting to use the GitHub OAuth plugin with GitHub Enterprise, I'm receiving a 500 status code after GitHub redirects back to Jenkins.
URL: http://ci.canon.rackspace.com/securityRealm/finishLogin?code=REDACTED
Stacktrace: https://gist.github.com/4623038
It's unclear to me whether this is an issue in the Java API bindings or the GitHub OAuth plugin.
When using the github authentication plugin for jenkins I'm getting:
java.io.FileNotFoundException: https://api.github.com/user/orgs
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1401)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at org.kohsuke.github.Requester.parse(Requester.java:298)
at org.kohsuke.github.Requester._to(Requester.java:175)
at org.kohsuke.github.Requester.to(Requester.java:141)
at org.kohsuke.github.GitHub.getMyOrganizations(GitHub.java:290)
at org.jenkinsci.plugins.GithubAuthenticationToken.(GithubAuthenticationToken.java:89)
at org.jenkinsci.plugins.GithubSecurityRealm.doFinishLogin(GithubSecurityRealm.java:366)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:298)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:161)
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:96)
at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:120)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:728)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:858)
at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:210)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:728)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:858)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:631)
at org.kohsuke.stapler.Stapler.service(Stapler.java:225)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1494)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:96)
at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:88)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:48)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:135)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.ApiTokenFilter.doFilter(ApiTokenFilter.java:64)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:46)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1474)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:949)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1011)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:701)
It seems as if github removed /user/orgs. /user/$user/orgs still works.
hi,
I`ve noticed that there is no support for:
"Create an issue"
"POST /repos/:user/:repo/issues"
Hi, this library is great!
can you add a support to retrieve all available labels for a repository?
https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
I've been able to list the repositories for a public organization:
GHOrganization org = gitHub.getOrganization("jenkinsci");
for (GHRepository r : org.getRepositories().values()) {
System.out.println("Repo: " + r.getName());
}
And I've been able to list the users for a private organization (I believe this should prove I'm successfully authenticating against that organization):
GHOrganization org = gitHub.getOrganization("merchantwarehouse");
List<GHUser> users = org.getMembers();
for (GHUser user : users) {
System.out.println("User: " + user.toString());
}
But when I try to list the repositories (all private) for the private organization, I get nothing. Have I missed a step?
My apologies if this is something that should have been obvious to me.
Thanks.
GitHub provides a Contents API [0]. I started to implement those methods and domain objects in the contents-api branch of my fork [1]. I'll create a pull-request once I consider my work mergeable.
btw, feel free to comment commits. Feedback are always welcome.
[0] http://developer.github.com/v3/repos/contents/
[1] https://github.com/acollign/github-api/tree/contents-api
Hi kohsuke,
I was using your api, it was great but there is this bug I hope you can fix it soon:
Whenever I call the function GHRepository.getIssues(GHIssueState.CLOSED), it returns a list of both issues and pull requests.
I expect only issue though. Currently my work around is to call getPullRequests then for each issue from getIssues, I search in the whole list of pull requests to see if it is already there. Then I ignore it. But this makes my algorithm runs at O(n*m).
Please fix it soon.
getRateLimit()
at https://github.com/kohsuke/github-api/blob/master/src/main/java/org/kohsuke/github/GitHub.java#L228 fails for GitHub Enterprise with a 404 status code, body of
{
"message": "No rate limit for white listed users"
}
GitHub Enterprise users are considered white listed and so don't have rate limits.
See also janinko/ghprb#127
The following test case shows that calling issue.getRepository().getIssue(issue.getNumber()) .getClosedBy()
at times yields different results from issue.getClosedBy().
Also not all closed issues return the GHuser
who closed them whereas github shows the closer of the issue.
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import org.junit.BeforeClass;
import org.junit.Test;
import org.kohsuke.github.GHIssue;
import org.kohsuke.github.GHIssueState;
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GitHub;
public class IssueTester {
private static GHRepository repo;
@BeforeClass
public static void setup() {
try {
repo = GitHub.connectAnonymously().getRepository(
"kohsuke/github-api");
} catch (IOException e) {
e.printStackTrace();
}
}
// These two ways of gettting closers must return same GHUser
@Test
public void testGetCloser() {
try {
for (GHIssue issue : repo.getIssues(GHIssueState.CLOSED)) {
assertEquals(issue.getRepository().getIssue(issue.getNumber())
.getClosedBy(), issue.getClosedBy());
}
} catch (IOException e) {
e.printStackTrace();
}
}
// Every closed issue must have been closed by someone
@Test
public void testClosedIssue() {
try {
for (GHIssue issue : repo.getIssues(GHIssueState.CLOSED)) {
assert (issue.getClosedBy() != null);
assert (issue.getRepository().getIssue(issue.getNumber())
.getClosedBy() != null);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Got this error:
{"message":"Validation Failed","documentation_url":"https://developer.github.com/v3/repos/#create","errors":[{"value":309572,"resource":"Repo","field":"team_id","code":"invalid"}]}
Is it due to an API update? Thank you.
API Documentation is here
I expected a method of the form of [1], but it looks like getCommitter
and getAuthor
return a User. Similarly, I expected [2] when looking for the user.
If there's a way to do this that I'm not aware of, please let me know.
[1] myGHCommit.getCommitter().getDate()
and myGHCommit.getAuthor().getDate()
[2] myGHCommit.getCommitter().getUser()
and myGHCommit.getAuthor().getUser()
The link to Javadoc currently points at http://github-api.kohsuke.org/apidocs/index.html, which seems incorrect.
Thanks.
https://github.com/blog/1160-github-api-v2-end-of-life
It means a lot of stuff in the API using V2 are broken. :(
Just installed the latest version of the plugin from Jenkins to deal with v1 and v2 github going away, and got this:
java.lang.NullPointerException
at org.acegisecurity.GrantedAuthorityImpl.hashCode(GrantedAuthorityImpl.java:62)
at org.acegisecurity.providers.AbstractAuthenticationToken.hashCode(AbstractAuthenticationToken.java:146)
at hudson.security.NotSerilizableSecurityContext.hashCode(NotSerilizableSecurityContext.java:80)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.storeSecurityContextInSession(HttpSessionContextIntegrationFilter.java:407)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:264)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:66)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
at winstone.RequestDispatcher.forward(RequestDispatcher.java:331)
at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:215)
at winstone.RequestHandlerThread.run(RequestHandlerThread.java:138)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
I wanted to export all the issues in to an excel.
API returns everything except 'ClosedBy'.
I'm using a private repository.
I'm glad if you could look into this.
(I Thank Kohsuke and all the contributors for making such a great API)
Hi, I am using the github-oauth-plugin on my jenkins instances. And I need an https proxy to reach github.com access points. Recently the plugin patched its oauth part with support for setting an http proxy via -Dhttps.proxyHost
& -Dhttps.proxyPort
arguments.
However, setting those is still not effective for retrieving user's github group list, which is backed by github-api. So is there a way can I set a proxy for github-api? or we need one
Occasionally a call to getEvents will throw with the following exception. I'm assuming this is just the github rest layer being flaky or somethimg, but just posting it, in case there's something else going on
ERROR 21:37:25 Failed fetching events from github
java.net.UnknownHostException: api.github.com
at java.net.InetAddress.getAllByName0(InetAddress.java:1250) ~[na:1.7.0_55]
at java.net.InetAddress.getAllByName(InetAddress.java:1162) ~[na:1.7.0_55]
at java.net.InetAddress.getAllByName(InetAddress.java:1098) ~[na:1.7.0_55]
at com.squareup.okhttp.internal.Dns$1.getAllByName(Dns.java:29) ~[okhttp-1.5.3.jar:na]
at com.squareup.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:232) ~[okhttp-1.5.3.jar:na]
at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124) ~[okhttp-1.5.3.jar:na]
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:233) ~[okhttp-1.5.3.jar:na]
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:180) ~[okhttp-1.5.3.jar:na]
at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:366) ~[okhttp-1.5.3.jar:na]
at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:319) ~[okhttp-1.5.3.jar:na]
at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:187) ~[okhttp-1.5.3.jar:na]
at com.squareup.okhttp.internal.http.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210) ~[okhttp-1.5.3.jar:na]
at com.squareup.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25) ~[okhttp-1.5.3.jar:na]
at org.kohsuke.github.Requester.parse(Requester.java:359) ~[github-api-1.53.jar:na]
at org.kohsuke.github.Requester._to(Requester.java:180) ~[github-api-1.53.jar:na]
at org.kohsuke.github.Requester.to(Requester.java:155) ~[github-api-1.53.jar:na]
Hi there,
it seems that the GHPullRequest.getMergeableState method doesn't work in current implementation. At least when i use the jenkins ghprb (github pull request builder plugin) it always builds the unmerged branch only because off the method returing false (though the pr is mergeable as confirmed in the github webinterface).
Based on the github api v3 the needed field is called "mergeable" (and a boolean).
It seems that "populate" doesn't fill in the "mergeable_state" member. Though i didn't find the code where it really fills in the object members.
Also it looks like in GHPullRequest.populate() the call to root.retrieve().to(url, this); is issued with an empty url object. At least i didn't spot where the url member (its a member of the parent class GHIssue) is initialised.
Would be great if you could comment on that one :o)
thx
Memphiz
When I tries to pull repositories of a user, I get all public repositories.
But the list does not show private repository at all.
github = GitHub.connectUsingOAuth(oAuthToken);
user = github.getMyself();
Map<String,String> repos = new HashMap<String,String>();
this.repos = user.getRepositories();
System.out.println(Repos.toString());
Currently GHPerson#getRepositories()
will only get the first 30 repositories. It would be useful (to me) to have a getAllRepositories
that returns a map of all my repositories, if there are a lot it would follow pagination links making several github api requests.
Would you be open to this enhancement? If so I'll work on a pull request.
Thanks
Hi,
just tried your plugin on jenkins with our internal enterprise github. This is only accessible via http (not https). The code to access the api always adds the "https://api" prefix in front of it.
Github-api plugin: 1.28
Oauth plugin: 0.12
If I have time I'll try to find a workaround... Maybe someone knows quickly how this could be fixed :-)
Christian
Btw, the stacktrace says "plain" connection because I've entered the URL to github in jenkins to be http://github.internal.net:80
Stack trace is attached,
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(InputRecord.java:523) at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:355) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:798) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1165) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1149) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1177) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234) at org.kohsuke.github.GitHub.parse(GitHub.java:300) at org.kohsuke.github.GitHub._retrieve(GitHub.java:186) at org.kohsuke.github.GitHub.retrieveWithAuth(GitHub.java:175) at org.kohsuke.github.GitHub.getMyself(GitHub.java:365) at org.kohsuke.github.GitHub.(GitHub.java:114) at org.kohsuke.github.GitHub.connectUsingOAuth(GitHub.java:145) at org.jenkinsci.plugins.GithubAuthenticationToken.(GithubAuthenticationToken.java:68) at org.jenkinsci.plugins.GithubSecurityRealm.doFinishLogin(GithubSecurityRealm.java:315) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:288) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:151) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:90) at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659) at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:203) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:488) at org.kohsuke.stapler.Stapler.service(Stapler.java:162) at javax.servlet.http.HttpServlet.service(HttpServlet.java:45) at winstone.ServletConfiguration.execute(ServletConfiguration.java:248) at winstone.RequestDispatcher.forward(RequestDispatcher.java:333) at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:376) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:95)
Github allows you to specify "sha" parameter multiple times while querying for commits. For eg., the case where we need commits from branch x from commit sha y, we could specify sha query parameter twice in the github api url. The current code has no way to achieve this scenario.
(This is related to Merge of pull request #86 . Commit : a409b4f)
Hi!
Can you add to project function to get tags of github repository?
http://developer.github.com/v3/orgs/members/#check-membership
GET /orgs/:org/members/:user
204 -> true
404 -> false
302 -> GET /orgs/:org/public_members/:user
204 -> true
404 -> false
I dug around the source but from what I see there are currently only methods to get GHPullRequest's from github. I'm hoping that's not the case of course. Is there support for creating a new pull request for a branch?
According to the GitHub API:
Requests that return multiple items will be paginated to 30 items by default.
Need to use PagedIterable<>
when retrieving repository issues in order to retrieve all issues.
1.47 seems to be the latest version published here
http://repo.jenkins-ci.org/public/org/kohsuke/github-api/
Would it be possible to publish 1.49 on there.
This blogpost explains the advantages of OkHttp's interface over HttpURLConnection
- it neatly supports separation of Request and Response, and offers an asynchronous Call interface:
http://corner.squareup.com/2014/06/okhttp-2.html
In order for github-api
to take full advantage of the superior OkHttp API - and to expose it to external users so that users can do async calls to the GitHub API - would probably require commiting to using OkHttp everywhere within the github-api
library, removing all usage of HttpURLConnection. This might feel like a big change, but it's mostly an internal one, so hopefully would not substantially impact consumers of the library, other than offering them additional functionality.
Amongst it's many consumers, OkHttp is also the engine that powers HttpUrlConnection as of Android 4.4, so it's a library that has a lot of traction and support.
See the OkHttp 'Recipes' documentation for code usage examples.
Would there be any interest in a pull-request that made this happen?
I tried to delete a file with 3MB from my repository. But to do that I need to call GHRepository.getFileContent
first and that leads to the following error:
Exception: {"message":"This API returns blobs up to 1 MB in size. The requested blob is too large to fetch via the API, but you can use the Git Data API to request blobs up to 100 MB in size.","documentation_url":"https://developer.github.com/v3/repos/contents/#get-contents","errors":[{"resource":"Blob","field":"data","code":"too_large"}]}
The same happens with GHRepository.createContent
.
Is there a way to use the git blobs api: https://developer.github.com/v3/git/blobs/?
This cool library deserves a OSGi bundle. I'm currently creating a bundle by wrapping the library with its not-so-common dependencies embed [0]. I kept the groupId and will keep the version aligned with the library.
I successfully tested this bundle on Adobe CQ 5.6.1 as-is. I'm also planning to write instructions for Apache Felix which might need the installation of some dependencies.
Feel free to comment commits, create issues. Feedback will be really appreciated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.