-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Critical
-
Component/s: github-branch-source-plugin
-
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
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