jenkinsci / jenkinsci/github-branch-source-plugin

[JENKINS-73783] GitHub branch source plugin cannot create webhooks

Open
#1,447 1 comment 0 reactions 0 assignees View on GitHub
component:github-branch-source-plugin imported-jira-issue priority:critical resolution:unresolved
Dominant language
Java
Stars
217
Forks
398
Avg merge
30m
Merged PRs (30d)
1

Description

I am using the github public app for fetching user github tokens. I have automated the flow using python requests, it uses github API with GitHub app's client secret and client ID to get the user access token. 

 

Then I use the automated flow to create a Jenkins multibranch pipeline job. The issue is that the generated token seems fine with all the permissions. But in Jenkins logs, I see the following error when creating a job with same credentials. I am using credentials with username and password and in place of password, I am using the access token which is obtained when user installs the github app. Following is the error log:

{{2024-09-16 13:13:57.649+0000 [id=800]   INFO    o.j.p.g.webhook.WebhookManager$1#run: GitHub webhooks activated for job github_app_Ali-Ascii310_131316939688 with [GitHubRepositoryName[host=github.com,username=Al

i-Ascii310,repository=test-repo]] (events: [PULL_REQUEST, PUSH])                                                                                                                                                   

2024-09-16 13:13:57.913+0000 [id=800]   WARNING c.c.j.GitHubRepositoryName$1#applyNullSafe: Failed to obtain repository com.cloudbees.jenkins.GitHubRepositoryName$1@​23adc276                                      

org.kohsuke.github.HttpException: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}                                                                                  

        at org.kohsuke.github.GitHubConnectorResponseErrorHandler$1.onError(GitHubConnectorResponseErrorHandler.java:72)                                                                                           

        at org.kohsuke.github.GitHubClient.detectKnownErrors(GitHubClient.java:504)                                                                                                                                

        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:464)                                                                                                                                      

        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:427)                                                                                                                                      

        at org.kohsuke.github.Requester.fetch(Requester.java:85)                                                                                                                                                   

        at org.kohsuke.github.GHRepository.read(GHRepository.java:149)                                                                                                                                             

        at org.kohsuke.github.GitHub.getRepository(GitHub.java:687)                                                                                                                                                

        at com.cloudbees.jenkins.GitHubRepositoryName$1.applyNullSafe(GitHubRepositoryName.java:227)                                                                                                               

        at com.cloudbees.jenkins.GitHubRepositoryName$1.applyNullSafe(GitHubRepositoryName.java:223)                                                                                                               

        at org.jenkinsci.plugins.github.util.misc.NullSafeFunction.apply(NullSafeFunction.java:18)                                                                                                                 

        at com.google.common.collect.Iterators$6.transform(Iterators.java:829)                                                                                                                                     

        at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:52)                                                                                                                         

        at com.google.common.collect.Iterators$5.computeNext(Iterators.java:672)                                                                                                                                   

        at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)                                                                                                                  

        at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)                                                                                                                           

        at com.google.common.collect.Iterators.tryFind(Iterators.java:779)                                                                                                                                         

        at com.google.common.collect.Iterables.tryFind(Iterables.java:704)                                                                                                                                         

        at org.jenkinsci.plugins.github.util.FluentIterableWrapper.firstMatch(FluentIterableWrapper.java:127)                                                                                                      

        at org.jenkinsci.plugins.github.webhook.WebhookManager.repoWithWebhookAccess(WebhookManager.java:175)                                                                                                      

        at org.jenkinsci.plugins.github.webhook.WebhookManager$2.applyNullSafe(WebhookManager.java:197)                                                                                                            

        at org.jenkinsci.plugins.github.webhook.WebhookManager$2.applyNullSafe(WebhookManager.java:193)                                                                                                            

        at org.jenkinsci.plugins.github.util.misc.NullSafeFunction.apply(NullSafeFunction.java:18)                                                                                                                 

        at com.google.common.collect.Iterators$6.transform(Iterators.java:829)                                                                                                                                     

        at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:52)                                                                                                                         

        at com.google.common.collect.Iterators$5.computeNext(Iterators.java:672)                                                                                                                                   

        at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)                                                                                                                  

        at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)                                                                                                                           

        at com.google.common.collect.Iterators$5.computeNext(Iterators.java:671)                                                                                                                                   

        at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)                                                                                                                  

        at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)                                                                                                                           

        at com.google.common.collect.Iterators.addAll(Iterators.java:366)                                                                                                                                          

        at com.google.common.collect.Lists.newArrayList(Lists.java:146)                                                                                                                                            

        at com.google.common.collect.Lists.newArrayList(Lists.java:132)                                                                                                                                            

        at org.jenkinsci.plugins.github.util.FluentIterableWrapper.toList(FluentIterableWrapper.java:148)                                                                                                          

        at org.jenkinsci.plugins.github.webhook.WebhookManager$1.run(WebhookManager.java:129)                                                                                                                      

        at hudson.util.SequentialExecutionQueue$QueueEntry.run(SequentialExecutionQueue.java:123)                                                                                                                  

        at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)  }}

 

When I click on validate, the credentials are ok in the job. Even if I don't use script to create the job, I get the same error. If you wish to look at the flow, see https://github.com/10x-Engineers/Cloud-V-git-automation/blob/main/controllers/new_job.py

---
Originally reported by alitariq4589, imported from: GitHub branch source plugin cannot create webhooks


  • status: Open
  • priority: Critical
  • component(s): github-branch-source-plugin
  • label(s): git, jenkins, plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-02

Raw content of original issue

I am using the github public app for fetching user github tokens. I have automated the flow using python requests, it uses github API with GitHub app's client secret and client ID to get the user access token. 

 

Then I use the automated flow to create a Jenkins multibranch pipeline job. The issue is that the generated token seems fine with all the permissions. But in Jenkins logs, I see the following error when creating a job with same credentials. I am using credentials with username and password and in place of password, I am using the access token which is obtained when user installs the github app. Following is the error log:

{{2024-09-16 13:13:57.649+0000 [id=800]   INFO    o.j.p.g.webhook.WebhookManager$1#run: GitHub webhooks activated for job github_app_Ali-Ascii310_131316939688 with [GitHubRepositoryName[host=github.com,username=Al
i-Ascii310,repository=test-repo]] (events: [PULL_REQUEST, PUSH])                                                                                                                                                   
2024-09-16 13:13:57.913+0000 [id=800]   WARNING c.c.j.GitHubRepositoryName$1#applyNullSafe: Failed to obtain repository com.cloudbees.jenkins.GitHubRepositoryName$1@23adc276                                      
org.kohsuke.github.HttpException: {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest","status":"401"}                                                                                  
        at org.kohsuke.github.GitHubConnectorResponseErrorHandler$1.onError(GitHubConnectorResponseErrorHandler.java:72)                                                                                           
        at org.kohsuke.github.GitHubClient.detectKnownErrors(GitHubClient.java:504)                                                                                                                                
        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:464)                                                                                                                                      
        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:427)                                                                                                                                      
        at org.kohsuke.github.Requester.fetch(Requester.java:85)                                                                                                                                                   
        at org.kohsuke.github.GHRepository.read(GHRepository.java:149)                                                                                                                                             
        at org.kohsuke.github.GitHub.getRepository(GitHub.java:687)                                                                                                                                                
        at com.cloudbees.jenkins.GitHubRepositoryName$1.applyNullSafe(GitHubRepositoryName.java:227)                                                                                                               
        at com.cloudbees.jenkins.GitHubRepositoryName$1.applyNullSafe(GitHubRepositoryName.java:223)                                                                                                               
        at org.jenkinsci.plugins.github.util.misc.NullSafeFunction.apply(NullSafeFunction.java:18)                                                                                                                 
        at com.google.common.collect.Iterators$6.transform(Iterators.java:829)                                                                                                                                     
        at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:52)                                                                                                                         
        at com.google.common.collect.Iterators$5.computeNext(Iterators.java:672)                                                                                                                                   
        at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)                                                                                                                  
        at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)                                                                                                                           
        at com.google.common.collect.Iterators.tryFind(Iterators.java:779)                                                                                                                                         
        at com.google.common.collect.Iterables.tryFind(Iterables.java:704)                                                                                                                                         
        at org.jenkinsci.plugins.github.util.FluentIterableWrapper.firstMatch(FluentIterableWrapper.java:127)                                                                                                      
        at org.jenkinsci.plugins.github.webhook.WebhookManager.repoWithWebhookAccess(WebhookManager.java:175)                                                                                                      
        at org.jenkinsci.plugins.github.webhook.WebhookManager$2.applyNullSafe(WebhookManager.java:197)                                                                                                            
        at org.jenkinsci.plugins.github.webhook.WebhookManager$2.applyNullSafe(WebhookManager.java:193)                                                                                                            
        at org.jenkinsci.plugins.github.util.misc.NullSafeFunction.apply(NullSafeFunction.java:18)                                                                                                                 
        at com.google.common.collect.Iterators$6.transform(Iterators.java:829)                                                                                                                                     
        at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:52)                                                                                                                         
        at com.google.common.collect.Iterators$5.computeNext(Iterators.java:672)                                                                                                                                   
        at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)                                                                                                                  
        at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)                                                                                                                           
        at com.google.common.collect.Iterators$5.computeNext(Iterators.java:671)                                                                                                                                   
        at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)                                                                                                                  
        at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)                                                                                                                           
        at com.google.common.collect.Iterators.addAll(Iterators.java:366)                                                                                                                                          
        at com.google.common.collect.Lists.newArrayList(Lists.java:146)                                                                                                                                            
        at com.google.common.collect.Lists.newArrayList(Lists.java:132)                                                                                                                                            
        at org.jenkinsci.plugins.github.util.FluentIterableWrapper.toList(FluentIterableWrapper.java:148)                                                                                                          
        at org.jenkinsci.plugins.github.webhook.WebhookManager$1.run(WebhookManager.java:129)                                                                                                                      
        at hudson.util.SequentialExecutionQueue$QueueEntry.run(SequentialExecutionQueue.java:123)                                                                                                                  
        at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)  }}

 

When I click on validate, the credentials are ok in the job. Even if I don't use script to create the job, I get the same error. If you wish to look at the flow, see https://github.com/10x-Engineers/Cloud-V-git-automation/blob/main/controllers/new_job.py

environment

```
Jenkins 2.426.1 (built from source)

Linux Kernel: 6.5.11

OS: Ubuntu 22.04.1 LTS

Browser: Google Chrome Version 128.0.6613.119 (Official Build) (64-bit)

OpenJDK version: openjdk 11.0.17 2022-10-18

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.