Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40359

Webhook registration fails for private Github repositories

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Component/s: github-plugin
    • 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
    • Similar Issues:

      Description

      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)
      
      

        Attachments

          Activity

          Hide
          integer Kanstantsin Shautsou added a comment -

          Is it org or user?

          Show
          integer Kanstantsin Shautsou added a comment - Is it org or user?
          Hide
          doublesharp Justin Silver added a comment -

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

          Show
          doublesharp Justin Silver added a comment - "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?
          Hide
          doublesharp Justin Silver added a comment -

          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.

          Show
          doublesharp Justin Silver added a comment - 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.
          Hide
          doublesharp Justin Silver added a comment -

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

          Show
          doublesharp Justin Silver added a comment - 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....
          Hide
          doublesharp Justin Silver added a comment - - edited

          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.

          Show
          doublesharp Justin Silver added a comment - - edited 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.

            People

            • Assignee:
              integer Kanstantsin Shautsou
              Reporter:
              doublesharp Justin Silver
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: