[JIRA] (JENKINS-40359) Webhook registration fails for private Github repositories

78 views
Skip to first unread message

jsilver@doublesharp.com (JIRA)

unread,
Dec 11, 2016, 2:49:03 AM12/11/16
to jenkinsc...@googlegroups.com
Justin Silver created an issue
 
Jenkins / Bug JENKINS-40359
Webhook registration fails for private Github repositories
Issue Type: Bug Bug
Assignee: Kirill Merkushev
Components: github-plugin
Created: 2016/Dec/11 7:48 AM
Environment: CentOS 7
Jenkins 2.35
GitHub API Plugin 1.80
GitHub Authentication plugin 0.25
GitHub Branch Source Plugin 1.5
GitHub plugin 1.24.0
Labels: github-plugin webhook github
Priority: Minor Minor
Reporter: Justin Silver

Registering webhooks for private repositories fails, however it is successful for public repositories using the same access token for my account. I am able to clone the repository in the job, so I believe that my user access is properly configured, and all of the repositories are under my account, so I should have admin access. The access token does contain admin:repo_hook, and seems to be configured correctly based on the registration succeeding for the public repositories.

I enabled logging based on the recommendation of the Github plugin and see the following:

Dec 10, 2016 10:31:51 PM FINE com.cloudbees.jenkins.GitHubWebHook$1 apply
Calling registerHooks() for PUBLIC_PROJECT

Dec 10, 2016 10:31:51 PM FINE com.cloudbees.jenkins.GitHubWebHook$1 apply
Calling registerHooks() for PRIVATE_PROJECT

Dec 10, 2016 10:31:51 PM INFO org.jenkinsci.plugins.github.webhook.WebhookManager$1 run
GitHub webhooks activated for job email-templates-mock with [GitHubRepositoryName[host=github.com,username=doublesharp,repository=PUBLIC_PROJECT]] (events: [PUSH, REPOSITORY])

Dec 10, 2016 10:31:51 PM INFO org.jenkinsci.plugins.github.webhook.WebhookManager$1 run
GitHub webhooks activated for job PRIVATE_PROJECT with [GitHubRepositoryName[host=github.com,username=doublesharp,repository=PRIVATE_PROJECT]] (events: [PUSH, REPOSITORY])

Dec 10, 2016 10:31:51 PM WARNING org.jenkinsci.plugins.github.webhook.WebhookManager$2 applyNullSafe
Failed to add GitHub webhook for GitHubRepositoryName[host=github.com,username=doublesharp,repository=PRIVATE_PROJECT]
java.lang.NullPointerException: There is no credentials with admin access to manage hooks on GitHubRepositoryName[host=github.com,username=doublesharp,repository=PRIVATE_PROJECT]
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:231)
	at org.jenkinsci.plugins.github.webhook.WebhookManager$2.applyNullSafe(WebhookManager.java:156)
	at org.jenkinsci.plugins.github.webhook.WebhookManager$2.applyNullSafe(WebhookManager.java:152)
	at org.jenkinsci.plugins.github.util.misc.NullSafeFunction.apply(NullSafeFunction.java:18)
	at com.google.common.collect.Iterators$8.next(Iterators.java:812)
	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:648)
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:647)
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
	at com.google.common.collect.Lists.newArrayList(Lists.java:138)
	at com.google.common.collect.Lists.newArrayList(Lists.java:119)
	at org.jenkinsci.plugins.github.util.FluentIterableWrapper.toList(FluentIterableWrapper.java:137)
	at org.jenkinsci.plugins.github.webhook.WebhookManager$1.run(WebhookManager.java:104)
	at hudson.util.SequentialExecutionQueue$QueueEntry.run(SequentialExecutionQueue.java:119)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	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)

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

gentoo.integer@gmail.com (JIRA)

unread,
Dec 11, 2016, 7:28:02 PM12/11/16
to jenkinsc...@googlegroups.com
Kanstantsin Shautsou commented on Bug JENKINS-40359
 
Re: Webhook registration fails for private Github repositories

How much github servers do you have in global settings?
Have you ensured that global user accepted invite to repository?

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 8:05:02 PM12/12/16
to jenkinsc...@googlegroups.com

Just one Github server - "https://api.github.com", using a Personal Access Token for my user.

Which global user are you referring to? My configuration is only using my personal Github user.

gentoo.integer@gmail.com (JIRA)

unread,
Dec 12, 2016, 8:07:03 PM12/12/16
to jenkinsc...@googlegroups.com

java.lang.NullPointerException: There is no credentials with admin access to manage hooks on GitHubRepositoryName[host=github.com,username=doublesharp,repository=PRIVATE_PROJECT]

Add Comment Add Comment
 

gentoo.integer@gmail.com (JIRA)

unread,
Dec 12, 2016, 8:07:16 PM12/12/16
to jenkinsc...@googlegroups.com

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 8:12:02 PM12/12/16
to jenkinsc...@googlegroups.com
Justin Silver edited a comment on Bug JENKINS-40359
 
Re: Webhook registration fails for private Github repositories
"doublesharp" is my Github username, and all of the repositories in my Jenkins install belong to that account. I am able to create the webhooks from Jenkins for the public repositories (like https://github.com/doublesharp/lru-cache-for-clusters-as-promised), however it does not create the webhooks for my private repositories. I am able to build the project private projects manually, or from manually created webhooks, so the "doublesharp" user is able to clone the private repository, which I assumed meant that it was configured correctly within the job. Does this user need to be configured elsewhere to access the API?

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 8:12:02 PM12/12/16
to jenkinsc...@googlegroups.com

"doublesharp" is my Github username, and all of the repositories in my Jenkins install belong to that account. I am able to create the webhooks from Jenkins for the public repositories (like https://github.com/doublesharp/lru-cache-for-clusters-as-promised), however it does not create the webhooks for my private repositories. I am able to build the project manually, or from manually created webhooks, so the "doublesharp" user is able to clone the private repository, which I assumed meant that it was configured correctly within the job. Does this user need to be configured elsewhere to access the API?

gentoo.integer@gmail.com (JIRA)

unread,
Dec 12, 2016, 8:14:02 PM12/12/16
to jenkinsc...@googlegroups.com

What scopes do you have for this user token that used in global configuration? Does it have private_repo? Please provide screenshot.

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 8:19:01 PM12/12/16
to jenkinsc...@googlegroups.com
Justin Silver updated an issue
 
Change By: Justin Silver
Attachment: Screen Shot 2016-12-12 at 5.15.35 PM.png

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 8:20:04 PM12/12/16
to jenkinsc...@googlegroups.com
Justin Silver commented on Bug JENKINS-40359
 
Re: Webhook registration fails for private Github repositories

I don't have "private_repo" available as a scope, but per the UI the "repo" scope should allow full access to private repositories.

Screenshot with selected scopes:

Looking at the full system log the stracktrace that I posted earlier is preceded by this error:

Failed to obtain repository com.cloudbees.jenkins.GitHubRepositoryName$1@603ff301
java.io.FileNotFoundException: {"message":"Not Found","documentation_url":"https://developer.github.com/v3"}
	at org.kohsuke.github.Requester.handleApiError(Requester.java:592)
	at org.kohsuke.github.Requester._to(Requester.java:272)
	at org.kohsuke.github.Requester.to(Requester.java:213)
	at org.kohsuke.github.GitHub.getRepository(GitHub.java:369)
	at com.cloudbees.jenkins.GitHubRepositoryName$1.applyNullSafe(GitHubRepositoryName.java:218)
	at com.cloudbees.jenkins.GitHubRepositoryName$1.applyNullSafe(GitHubRepositoryName.java:214)
	at org.jenkinsci.plugins.github.util.misc.NullSafeFunction.apply(NullSafeFunction.java:18)
	at com.google.common.collect.Iterators$8.next(Iterators.java:812)
	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:648)
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:647)
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
	at com.google.common.collect.Iterators.tryFind(Iterators.java:757)
	at com.google.common.collect.Iterables.tryFind(Iterables.java:671)
	at org.jenkinsci.plugins.github.util.FluentIterableWrapper.firstMatch(FluentIterableWrapper.java:126)
	at org.jenkinsci.plugins.github.webhook.WebhookManager$2.applyNullSafe(WebhookManager.java:180)
	at org.jenkinsci.plugins.github.webhook.WebhookManager$2.applyNullSafe(WebhookManager.java:175)
	at org.jenkinsci.plugins.github.util.misc.NullSafeFunction.apply(NullSafeFunction.java:18)
	at com.google.common.collect.Iterators$8.next(Iterators.java:812)
	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:648)
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
	at com.google.common.collect.Iterators$7.computeNext(Iterators.java:647)
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143)
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138)
	at com.google.common.collect.Lists.newArrayList(Lists.java:138)
	at com.google.common.collect.Lists.newArrayList(Lists.java:119)
	at org.jenkinsci.plugins.github.util.FluentIterableWrapper.toList(FluentIterableWrapper.java:147)
	at org.jenkinsci.plugins.github.webhook.WebhookManager$1.run(WebhookManager.java:127)
	at hudson.util.SequentialExecutionQueue$QueueEntry.run(SequentialExecutionQueue.java:119)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	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/repos/doublesharp/PRIVATE_REPOSITORY
	at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
	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:524)
	at org.kohsuke.github.Requester._to(Requester.java:251)
	... 36 more

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 8:22:05 PM12/12/16
to jenkinsc...@googlegroups.com

I forgot to mentioned that I am replacing the real private repository name with "PRIVATE_REPOSITORY" in the error logs.

gentoo.integer@gmail.com (JIRA)

unread,
Dec 12, 2016, 8:23:01 PM12/12/16
to jenkinsc...@googlegroups.com

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 8:34:02 PM12/12/16
to jenkinsc...@googlegroups.com

"doublesharp" is a user account.

I'm still trying to debug on my end, and now I'm seeing strange behavior. I have 7 total jobs, with 4 public and 3 private. When I submitted this issue the 4 public repositories worked and all 3 private repositories were failing, however now only 1 private is failing and the others are successful. I manually deleted the webhook and verified that it was recreated by Jenkins when I saved the project configuration.

I don't see any meaningful differences between the configurations, so I wonder if maybe the issue is actually with Github?

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 8:53:02 PM12/12/16
to jenkinsc...@googlegroups.com

I created a new private repository with only a README.md and copied the failing job only replacing the git URL with the new project name and it successfully created the webhooks. I also copied the failing job and just ran it without success. This seems to me to point to an error on Github's side, not Jenkins.

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 8:59:01 PM12/12/16
to jenkinsc...@googlegroups.com

I renamed the repository in Github "project" to "project2" and then changed the URL in the job configuration, and when I saved the webhook was created on Github. I then deleted the webhook, renamed the project back to the original name, removed the 2 from the Jenkins config, and once it again it was able to create the webhooks when I saved.

It seems that something was in fact messed up with my project on Github and renaming it seems to have fixed it....

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 9:02:01 PM12/12/16
to jenkinsc...@googlegroups.com
Justin Silver resolved as Not A Defect
 

Authentication error seems to be with Github even with proper Jenkins configuration. Some projects resolved the issue on their own, the remaining project was corrected by renaming to an arbitrary value and then back to the original name.

Change By: Justin Silver
Status: Open Resolved
Resolution: Not A Defect

jsilver@doublesharp.com (JIRA)

unread,
Dec 12, 2016, 9:03:01 PM12/12/16
to jenkinsc...@googlegroups.com
Justin Silver edited a comment on Bug JENKINS-40359
 
Re: Webhook registration fails for private Github repositories
Authentication error seems to be with Github even with proper Jenkins configuration. Some projects resolved the issue on their own, the remaining project was corrected by renaming on Github to an arbitrary value and then back to the original name.
Reply all
Reply to author
Forward
0 new messages