-
Bug
-
Resolution: Unresolved
-
Critical
-
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