GithubHelp home page GithubHelp logo

hub4j / github-api Goto Github PK

View Code? Open in Web Editor NEW
1.1K 1.1K 716.0 51.91 MB

Java API for GitHub

Home Page: https://github-api.kohsuke.org/

License: MIT License

Java 100.00%
api client-library github github-api github-api-v3 java java-api

github-api's People

Contributors

bitwiseman avatar blacelle avatar bloslo avatar cmoulliard avatar dbaur avatar dependabot-preview[bot] avatar dependabot[bot] avatar ecxia avatar farmdawgnation avatar gsmet avatar ingwarsw avatar janinko avatar jglick avatar jimmysombrero avatar jlengrand avatar johnou avatar kgromov avatar kohsuke avatar kostyasha avatar madhephaestus avatar marcoferrer avatar martinvanzijl avatar mocleiri avatar paulomigalmeida avatar seregamorph avatar stephenc avatar t0m4uk1991 avatar tginiotis-at-work avatar timja avatar xiongkezhi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

github-api's Issues

ClosedBy returns nothing for closed issues

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)

github /user/orgs fails

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.

add support for proxy

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

GitHub.connectAnonymously() fails because of a lack of credentials.

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)

Getting private repositories for a private organization

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.

Unable to access commit date through api.

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()

getReadme its outdated

You either use this:
/repos/:owner/:repo/readme

Or you just change it to this:

GHContent getReadme(){
return getFileContent("README.md");
}

Consider committing to using OkHttp in preference to HttpURLConnection

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?

GHUser is missing a getHTMLURL() method

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

Different ways of getting issue.getClosedby() return different results.

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();
        }
    }
}

NPE Crash on 1.27

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)

Provide OSGi bundle

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.

[0] https://github.com/acollign/github-api-osgi

Error while accessing rate limit API - No subject alternative DNS name matching api.github.com found.

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
?

Throwing an Error when an IOException occurs is overly fatal

https://github.com/kohsuke/github-api/blob/master/src/main/java/org/kohsuke/github/Requester.java#L268

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.

Add support for commit status contexts.

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! :)

NullPointerException in GHPerson

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)
(...)

Suggested enhancement: GHPerson#getAllRepositories()

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

File size limited to 1MB

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/?

github-api does in not correctly distinguish between user and organisation ownership

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

GHUser.getRepositories() does not pull private repositories

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());

Cannot create repository in organisation

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.

GHRepository assumes public github.com, won't work with github enterprise

https://github.com/kohsuke/github-api/blob/master/src/main/java/org/kohsuke/github/GHRepository.java#L96

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.

create pull requests?

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?

Enterprise Github without HTTPS not supported

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)

GHRepository.getIssues(GHIssueState.CLOSED) also return pull requests

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.

getEvents fails periodically with odd exception

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]

getMergeableState in GHPullRequest doesn't work

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

GHIssue.getComments() throws NoSuchElementException when there are no comments

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.