-
Bug
-
Resolution: Won't Fix
-
Minor
-
None
-
Jenkins 2.1, github-organization-folder 1.3, github-api 1.75
-
Powered by SuggestiMate
When creating a new job for a GitHub org, I'm seeing the following in the Jenkins logs:
WARNING: Failed to register GitHub Org hook to https://github.com/karlmdavis (missing permissions?): {"message":"Not Found","documentation_url":"https://developer.github.com/v3"} May 04, 2016 8:03:46 PM org.jenkinsci.plugins.orgfolder.github.MainLogic applyOrg WARNING: Failed to register GitHub Org hook to https://github.com/HHSIDEAlab (missing permissions?): {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}
I did confirm that the personal access token I'm using has the admin:repo_hook permission, as well as admin:org_hook. Not sure what else to check.
The plugin seems to work correctly aside from this: it finds projects with Jenkinsfile s and builds them when asked. Just no webhook triggers.
[JENKINS-34612] Jenkins 2.1 not registering GitHub org webhooks: "WARNING: Failed to register GitHub Org hook to ..."
Unbelievable. Thank you karlmdavis! Cost me probably a day as well, could have been worse!
In my case, it was not that. It seems that the only way to avoid this error is to add the Jenkins user as an organisation owner. Being an admin is not enough, it has to be an owner, which is really worrying as an owner can wipe the entire organisation with two clicks.
I really doubt this is about case-sensitivity here because I get the same message even if the organization name and full-name do match on both Jenkins job and GitHub. Both strings are identical, same case, no special characters or prefix or suffix spaces.
Failed to register GitHub Org hook to https://github.com/bmlltest (missing permissions?): {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}
Same issue here. And I believe it is not case-sensitivity issue in my case.
Same issue encountered on the following environment:
Jenkins 2.16
GitHub API Plugin 1.76
GitHub Branch Source Plugin 1.8.1
GitHub Organization Folder Plugin 1.4
GitHub plugin 1.20.0
Pipeline 2.2
Steps to reproduce:
1 - New Item
2 - Enter GitHub organization name
3 - Select "GitHub organization"
4 - Click OK
Stack trace:
Aug 04, 2016 8:14:26 PM WARNING org.jenkinsci.plugins.orgfolder.github.MainLogic applyOrg Failed to register GitHub Org hook to https://github.com/crash-test-dummies (missing permissions?): {"message":"Not Found","documentation_url":"https://developer.github.com/v3"} Aug 04, 2016 8:14:26 PM FINE org.jenkinsci.plugins.orgfolder.github.MainLogic null java.io.FileNotFoundException: {"message":"Not Found","documentation_url":"https://developer.github.com/v3"} at org.kohsuke.github.Requester.handleApiError(Requester.java:553) at org.kohsuke.github.Requester._to(Requester.java:264) at org.kohsuke.github.Requester.to(Requester.java:205) at org.kohsuke.github.GHHooks$Context.getHooks(GHHooks.java:25) at org.kohsuke.github.GHOrganization.getHooks(GHOrganization.java:276) at org.jenkinsci.plugins.orgfolder.github.MainLogic.existsHook(MainLogic.java:198) at org.jenkinsci.plugins.orgfolder.github.MainLogic.applyOrg(MainLogic.java:89) at org.jenkinsci.plugins.orgfolder.github.ItemListenerImpl.maybeApply(ItemListenerImpl.java:41) at org.jenkinsci.plugins.orgfolder.github.ItemListenerImpl.onUpdated(ItemListenerImpl.java:29) at hudson.model.listeners.ItemListener$3.apply(ItemListener.java:195) at hudson.model.listeners.ItemListener$3.apply(ItemListener.java:193) at hudson.model.listeners.ItemListener.forAll(ItemListener.java:167) at hudson.model.listeners.ItemListener.fireOnUpdated(ItemListener.java:193) at com.cloudbees.hudson.plugins.folder.AbstractFolder.save(AbstractFolder.java:667) at hudson.util.PersistedList.onModified(PersistedList.java:173) at hudson.util.PersistedList._onModified(PersistedList.java:181) at hudson.util.PersistedList.add(PersistedList.java:72) at jenkins.branch.CustomOrganizationFolderDescriptor.newInstance(CustomOrganizationFolderDescriptor.java:109) at hudson.model.ItemGroupMixIn.createProject(ItemGroupMixIn.java:323) at hudson.model.ItemGroupMixIn.createTopLevelItem(ItemGroupMixIn.java:203) at jenkins.model.Jenkins.doCreateItem(Jenkins.java:3669) 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:498) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:324) at org.kohsuke.stapler.interceptor.RequirePOST$Processor.invoke(RequirePOST.java:52) at org.kohsuke.stapler.PreInvokeInterceptedFunction.invoke(PreInvokeInterceptedFunction.java:26) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:167) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:100) at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:124) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649) at org.kohsuke.stapler.Stapler.service(Stapler.java:238) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135) at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:80) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) 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:142) 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 jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93) 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:171) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77) 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.io.FileNotFoundException: https://api.github.com/orgs/crash-test-dummies/hooks at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:240) at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210) at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25) at org.kohsuke.github.Requester.parse(Requester.java:492) at org.kohsuke.github.Requester._to(Requester.java:243) ... 85 more
I can confirm that once user is made owner of the GH organization, then even with the initial errors (due to unauthenticated requests), the Webhook is properly added if the proper credential is specified when adding the new item.
Confirming gtirloni's findings, being organization admin wasn't enough, after making user an organization owner, webhook was created.
The GitHub Org Folders plugin is being tombstoned.
The functionality provided by the GitHub Org Folders plugin has been significantly refactored and migrated to the GitHub Branch Source plugin.
Please verify if this issue is an issue with GitHub Branch Source 2.0.0-beta-1 (available from the experimental update center now or 2.0.0 (available in early January 2017)
I've got that issue with GitHub Branch Source plugin, except that the error message from GitHub seems to change over the years.
I got 4 identical GitHub Orgs, all accessed by a GitHub App. First one went fine, hook created no problems. The other 3 all fails with the error message:
Failed to register GitHub Org hook to https://github.com/**** (missing permissions?): https://api.github.com/orgs/****/hooks {"message":"Resource not accessible by integration","documentation_url":"https://docs.github.com/rest/reference/orgs#list-organization-webhooks"}
All orgs are using exactly the same one GitHub App. I couldn't reproduce that issue locally with other github orgs.
Ah, there's a clue. The one org that was successful actually owns that GitHub App, the other ones are just have it installed.
GitHub support got back to me with the following finding: each application installation has its own token. Seems like my Jenkins instance was using the same token for all the installations. Further diving into the issue, the `Owner` field description for GitHub App credentials entry reads as this:
The organisation or user that this app is to be used for. Only required if this app is installed to multiple organisations.
This is not the owner of the App, it is an org that has this app installed! The name of the field is confusing. Also I am still confused as my Jenkins instance was successfully able to access private repos with the "wrong" token, it's just failing to manage webhooks.
However, that means for each org I need to have its own credentials entry, even though it is the same App ID and key? I'm not sure this is expected/desired behavior. I want to be able to create the App and add its ID and token to my Jenkins instance, and then I want my Jenkins users to be able to install this App to their orgs and when they create jobs they should be able to use GitHub App credentials entry corresponding to this app. Current behavior requires me to be adding credentials entry separately for each org.
I haven't looked into the code, but it should be possible to dynamically inject the `Owner` field before requesting the token based on the current SCM configuration in the job.
I have filed https://issues.jenkins.io/browse/JENKINS-64249 to fix typos and improve documentation.
I was going to file an improvement request based on the above comment, but it seems like there is two similar issues already open:
https://issues.jenkins.io/browse/JENKINS-62220
https://issues.jenkins.io/browse/JENKINS-62594
Blargh, I just figured out what the problem was. Hat tip to this fine fellow for the clue I needed: https://github.com/juretta/hudson-github-plugin/issues/4#issuecomment-56458604. The bug is actually a case-sensitivity issue.
The log entries I included in my issue description were a red herring: a webhook was automatically created (I just missed it), and was being fired from GitHub as expected, and was even being received by Jenkins. Unfortunately, though, Jenkins was ignoring the hook events, because my organization name in Jenkins was cased as HHSIDEALab, rather than as HHSIDEAlab (which is how it's cased in GitHub and in the hook events).
Hilariously, this blew a whole day for me. I know it's a super minor problem in the grand scheme of things, but if you folks could fix the issue, or at least add a useful error/warning in the logs, that'd be super helpful to "future me"s.