Github App - Authentication failed for 'https://github.com/

My Jenkins uses mainly Github App as credentials. Recently I had an issue with those Github Apps used as credentials for Repository URL:

  1. Job → Configure:
   Failed to connect to repository : Command "/usr/bin/git ls-remote -h -- https://github.com/owner/repo HEAD" returned status code 128:
   stdout: 
   stderr: remote: Repository not found.
   fatal: Authentication failed for ' https://github.com/owner/repos/ '
  1. After build:
Started by user USER

 hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --force --progress --prune -- origin +refs/heads/main:refs/remotes/origin/main" returned status code 128:
 stdout: 
 stderr: remote: Repository not found.
 fatal: Authentication failed for 'https://github.com/owner/repo/'
 	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2852)
 	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2193)
 	at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:638)
 	at PluginClassLoader for git//jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:404)
 Caused: java.io.IOException
 	at PluginClassLoader for git//jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:409)
 	at PluginClassLoader for scm-api//jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:219)
 	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:123)
 	at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:70)
 	at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:342)
 	at hudson.model.ResourceController.execute(ResourceController.java:97)
 	at hudson.model.Executor.run(Executor.java:456)

Recently I’ve upgraded plugin Github Branch Source to 1986.v801e40614d00 from 1983.vfa_27ed961853 and it seems ok but this issue occurs non-deterministically.

Jenkins setup:

Jenkins installed via rpm on RHEL9, started via systemd.

git --version
git version 2.52.0

Jenkins: 2.568.3
OS: Linux - 5.14.0-687.57.1.el9_8.x86_64
Java: 25.0.4.1 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)

Plugins:
Office-365-Connector:5.3.1
SquishPlugin:8.6
active-directory:2.967.vf4e254546a_b_3
additional-identities-plugin:183.219.v3f2387982f0c
analysis-model-api:14.17.0-1026.v569d23ce841e
ansible:635.v34b_48e979c86
ansicolor:542.v03d235fee02d
ant:520.vd082ecfb_16a_9
antisamy-markup-formatter:173.v680e3a_b_69ff3
anything-goes-formatter:39.v625a_b_b_d4d1a_a\_
apache-httpcomponents-client-4-api:4.5.14-269.vfa_2321039a_83
apache-httpcomponents-client-5-api:5.6.4-204.vfa_29df89ffcf
asm-api:9.10.1-216.va_9256d3b_844b\_
audit-trail:456.v39d2fd1ed556
authentication-tokens:1.144.v5ff4a_5ec5c33
aws-credentials:265.v8422a_f384cd9
aws-java-sdk-ec2:1.12.780-480.v4a_0819121a_9e
aws-java-sdk-minimal:1.12.780-480.v4a_0819121a_9e
aws-java-sdk2-core:2.42.33-70.vd69c0763fa_60
aws-java-sdk2-ec2:2.42.33-70.vd69c0763fa_60
azure-credentials:426.v5627e6a_4c7a_7
azure-sdk:292.v2db_0b_b_b_50d35
backup-interrupt-plugin:17.va_b_50ca_9df8d0
basic-branch-build-strategies:317.v85b_331d6cc42
blueocean:1.27.26
blueocean-autofavorite:1.2.5
blueocean-bitbucket-pipeline:1.27.26
blueocean-commons:1.27.26
blueocean-config:1.27.26
blueocean-core-js:1.27.26
blueocean-dashboard:1.27.26
blueocean-display-url:2.4.4
blueocean-events:1.27.26
blueocean-git-pipeline:1.27.26
blueocean-github-pipeline:1.27.26
blueocean-i18n:1.27.26
blueocean-jira:1.27.26
blueocean-jwt:1.27.26
blueocean-personalization:1.27.26
blueocean-pipeline-api-impl:1.27.26
blueocean-pipeline-editor:1.27.26
blueocean-pipeline-scm-api:1.27.26
blueocean-rest:1.27.26
blueocean-rest-impl:1.27.26
blueocean-web:1.27.26
bootstrap5-api:5.3.8-1048.va_c299057e35c
bouncycastle-api:2.30.1.85.2-304.v4b_5b_62e59a_a_7
branch-api:2.1280.v0d4e5b_b_460ef
build-blocker-plugin:177.ve433d85b_3fd7
build-discarder:158.vce570d01ce4c
build-monitor-plugin:1131.va_2d8e68fc912
build-name-setter:2.5.1
build-timeout:1.41
build-timestamp:1.1.1
build-token-root:365.v717f8685a_09e
build-user-vars-plugin:214.va_eed2ed849ca\_
buildtriggerbadge:343.vb_693d3ceda_44
built-on-column:1.5
caffeine-api:3.2.4-208.v7e2da_a_7db_82b\_
checkmarx:2025.4.1
checks-api:422.vc7e8b_51488c6
cloud-stats:423.v63f017a_f582c
cloudbees-bitbucket-branch-source:937.3.10
cloudbees-disk-usage-simple:275.v56e74c9dd0d3
cloudbees-folder:6.1106.v3a_d9a_6d2465e
command-launcher:141.v9578cf36b_311
commons-collections4-api:4.5.0-8.va_d5448ef9011
commons-compress-api:1.28.0-91.vf86a_34dfa_c1d
commons-httpclient3-api:3.1-3
commons-lang3-api:3.20.0-109.ve43756e2d2b_4
commons-text-api:1.15.0-218.va_61573470393
config-file-provider:1013.v73c323e52b_1f
configuration-as-code:2121.v86fe99d4b_b_a_b\_
configurationslicing:712.v727fec97b_b_b_9
copyartifact:795.ve8e151429b_27
cors-filter:21.v34a_0a_7179a_5a\_
coverage:3.3373.v2dc29d8d7a_d0
credentials:1511.v2e3cb_0008ef0
credentials-binding:728.v902a_273b_8947
cucumber-reports:5.11.0
custom-folder-icon:2.969.v365a_90fb_5d3b\_
custom-tools-plugin:0.8
customizable-header:330.v8a_8d87511ea_1
dark-theme:652.vea_da_dfea_e769
dashboard-view:2.558.v96b_901978e47
data-tables-api:2.3.8-1570.v1cb_1cd2a_0fb_c
dependency-check-jenkins-plugin:5.6.5
disable-github-multibranch-status:1.2
display-url-api:2.217.va_6b_de84cc74b\_
docker-commons:477.v289085a_b_6896
docker-java-api:3.7.1-136.v5d70f77a_c3d6
docker-plugin:1327.v9524f1ee134e
docker-workflow:653.v2f2c08eff0ec
downstream-build-cache:1.7
dtkit-api:3.0.3
durable-task:686.v80ff80875b_82
echarts-api:6.1.0-1321.v86c4c5114494
eddsa-api:0.3.0.1-29.v67e9a_1c969b_b\_
email-ext:2038.v7b_8817a_499d9
emailext-template:249.v81d6ea_f33f2e
embeddable-build-status:666.vcb_0de9eb_43d8
emoji-symbols-api:17.0-57.v8d44b_9a_b_d5ea\_
envinject:2.941.v351a_20c0a_3ca\_
envinject-api:1.241.vdd714803b_403
extended-choice-parameter:388.ve7b_d0b_920e10
extensible-choice-parameter:255.vfa_41f46828ef
extra-tool-installers:234.v67a_eca_496b_8b\_
favorite:2.267.vb_90d08408081
file-parameters:433.va_0b_80359d54d
flatpickr-api:4.6.13-32.v60a_51029c136
folder-properties:97.v0c61a_c452eb_b\_
font-awesome-api:7.3.1-1013.v0835a_879ec6d
forensics-api:4.1923.v445c56df9b_2e
generic-webhook-trigger:2.4.3
git:5.10.1
git-client:6.6.1
git-parameter:462.463.v496a_59f698e5
github:1.47.0
github-api:1.330-492.v3941a_032db_2a\_
github-branch-source:1983.vfa_27ed961853 -> updated to 1986.v801e40614d00
github-checks:679.v74133da_b_435a\_
gradle:2.20.1253.vc116f0763a_eb\_
groovy:537.v741a_5a_f1b_581
gson-api:2.14.0-201.v8eefe5515533
handy-uri-templates-2-api:2.1.8-38.vcea_5d521d5f3
htmlpublisher:429
instance-identity:203.v15e81a_1b_7a_38
ionicons-api:94.vcc3065403257
jackson-annotations2-api:2.22-19.v10a_a_582ea_26e
jackson2-api:2.22.2-445.vdc613f1d8012
jackson3-api:3.2.2-96.v599957900a_1a\_
jakarta-activation-api:2.1.4-1
jakarta-mail-api:2.1.5-1
jakarta-xml-bind-api:4.0.9-19.v2b_a_5b_44d9a_1c
javadoc:354.vee1a_660b_4990
javax-activation-api:1.2.0-8
javax-mail-api:1.6.2-11
jaxb:2.3.9-143.v5979df3304e6
jdk-tool:83.v417146707a_3d
jenkins-design-language:1.27.26
jersey2-api:2.48-180.ve47b_264f849b\_
jira:3.22
jjwt-api:0.13.0-141.vd58b_a_9592b_6c
job-dsl:3732.v9a_c49a_61a_313
jobConfigHistory:1380.v762185b_9a_793
joda-time-api:2.14.3-200.v65623733c99f
jqs-monitoring:37.vf50a_82a_0b_f32
jquery:1.12.4-3
jquery3-api:3.7.1-687.v68d468e40b_30
jsch:0.2.16-95.v3eecb_55fa_b_78
json-api:20260814-226.v20f9685d642c
json-path-api:3.0.0-218.vcd4dd1355de2
jsoup:1.23.2-106.v1161f282b_eb_f
junit:1425.v9c7318dca_96d
kubernetes:4557.ve746270f672f
kubernetes-cli:1.375.v8001982544ba
kubernetes-client-api:7.3.1-256.v788a_0b_787114
kubernetes-credentials:207.v492f58828b_ed
ldap:825.v2fca_37dd5b_cb\_
leastload:71.vb_585f7a_dc4f5
lenientshutdown:2.125.v1156982d427d
locale:641.v84f22d75fd8b\_
lockable-resources:1560.va_b_cd589f23eb\_
login-theme:337.vf8d01ca_1e783
mailer:534.v1b_36f5864073
mapdb-api:1.0.9-44.va_1e1310c9118
mask-passwords:220.v95819055b_265
matrix-auth:3.3
matrix-project:917.v22eda_817646e
maven-plugin:3.27
mcp-server:0.203.v12a_6f2a_01d72
mercurial:1323.ve69d2a_db_8a_b_d
metrics:4.2.37-494.v06f9a_939d33a\_
mina-sshd-api-common:2.19.0-192.v2b_a_7b_2c1dc71
mina-sshd-api-core:2.19.0-192.v2b_a_7b_2c1dc71
monitoring:2.8.0
netty-api:4.2.18.Final-34.v861b_21a_78c0f
next-build-number:66.v4b_4762172d53
nexus-artifact-uploader:2.16
nodejs:1.6.6
nodelabelparameter:851.vd94e5048d321
okhttp-api:5.3.2-200.vedb_720a_cf1f8
oss-symbols-api:465.v25d9fdc88c26
ownership:373.vb_41d439617c2
pam-auth:1.12
parameter-separator:334.v1fc0e534c71d
parameterized-trigger:893.va_383a_9b_a_4c11
people-view:1.16.v774d3b_4b_3a_f3
percentage-du-node-column:0.1.0
performance:1018.ve732b_08d5600
permissive-script-security:0.7
pipeline-build-step:601.v6d4c6d1a_9dc7
pipeline-github-lib:65.v203688e7727e
pipeline-graph-analysis:254.v0f63a_a_447dca\_
pipeline-graph-view:1013.v9f83fd83c063
pipeline-groovy-lib:806.v408277b_33d1d
pipeline-input-step:560.v56198a_642157
pipeline-maven:1760.v9a_a_e6dcb_0444
pipeline-maven-api:1760.v9a_a_e6dcb_0444
pipeline-milestone-step:152.v6e22b_8cfc66c
pipeline-model-api:2.2293.v6e7193cec599
pipeline-model-definition:2.2293.v6e7193cec599
pipeline-model-extensions:2.2293.v6e7193cec599
pipeline-npm:503.vf29ef1b_913ce
pipeline-rest-api:2.41
pipeline-stage-step:345.va_96187909426
pipeline-stage-tags-metadata:2.2293.v6e7193cec599
pipeline-stage-view:2.41
pipeline-utility-steps:3.810.va_7672d206740
plain-credentials:199.v9f8e1f741799
platformlabeler:3421.vcc413d2b_20b_f
plugin-util-api:7.1341.v039f146993d9
prism-api:1.30.0-741.v034eb_0b_0a_a_fa\_
prometheus:860.v532442b_44e9a\_
pubsub-light:1.19
purge-build-queue-plugin:125.v09ee2147746f
purge-job-history:74.vf21030329dda\_
pyenv-pipeline:2.1.2
rebuild:338.va_0a_b_50e29397
resource-disposer:0.25
robot:6.3.0
role-strategy:898.vc050ed2424ca\_
saferestart:102.v4dc1b_9636a_ee
schedule-build:696.v0a_b_ec7334c89
scm-api:728.vc30dcf7a_0df5
scmskip:84.v50575d32b_23f
script-security:1429.v0810f1b_530f5
shelve-project-plugin:3.3196.v0052de37a_8d3
sidebar-link:2.5.0
sidebar-update-notification:1.1.0
simple-theme-plugin:230.v8b_fd91b_b_800c
slack:795.v4b_9705b_e6d47
snakeyaml-api:2.5-149.v72471e9c6371
snakeyaml-engine-api:3.1.1-12.v4320c7d6f89c
sonar:2.19.0
sse-gateway:1.29
ssh:159.v496ca_25e5e82
ssh-agent:433.v9e73d67c3f74
ssh-credentials:372.va_250881b_08cd
ssh-slaves:3.1097.v868116049892
sshd:3.384.vc89b_5e138cf9
structs:362.va_b_695ef4fdf9
subversion:1327.vc36e0019a_653
support-core:1865.v45d40b_778b_cb\_
terraform:1.0.10
theme-manager:346.v06cca_64c6a_37
thinBackup:2.1.5
timestamper:1.30
token-macro:477.vd4f0dc3cb_cf1
trilead-api:2.284.v1974ea_324382
uno-choice:2.8.10
validating-string-parameter:345.v0f4330488a_f6
variant:70.va_d9f17f859e0
versioncolumn:400.v3c5c3004f31d
warnings-ng:13.10266.vefe0a_717b_e11
woodstox-core-api:7.2.2-10.vcb_629759b_2c2
workflow-aggregator:608.v67378e9d3db_1
workflow-api:1413.v2ff1a_5e720fa\_
workflow-basic-steps:1098.v808b_fd7f8cf4
workflow-cps:4383.v04fa_a_3d67b_d9
workflow-durable-task-step:1479.v56e587f413a_7
workflow-job:1600.v6f36ed83529d
workflow-multibranch:842.v3a_b_59b_57b_e6e
workflow-scm-step:487.v41313a_96b_65d
workflow-step-api:724.v538c2362b_dfb\_
workflow-support:1015.v785e5a_b_b_8b_22
ws-cleanup:0.49
xray-connector:2.6.2
xunit:3.1.7
xvfb:1.2
yet-another-build-visualizer:1.17

Probably an issue with Github Branch plugin. Reboot didn’t help but upgrade probably yes. Jenkins has not been upgraded recently.

The problem still exists. Upgrade didn’t help. There are issues on Github,

Check the GitHub App installation and permissions on the org and repo, and confirm which credentials the branch source is actually using after the plugin upgrade. I wrote the longer version up here https://vectle.com/skills/skl_AF3k1VDj6DEE6dQDFj3klA with the checks in order, starting with the app installation and the credential the job picks up. The intermittent Repository not found on ls-remote usually means the app token has no access to that repo rather than a network problem.

Your stack trace goes through CpsScmFlowDefinition and GitSCMFileSystem, so this failure is while loading the Jenkinsfile, before the Pipeline can run an agent checkout. Are the affected jobs configured as “Pipeline script from SCM” with Lightweight checkout enabled, or as Multibranch Pipelines? Comparing that job-level SCM credential ID with the branch-source credential ID would help identify which path is failing before attributing it to the Branch Source upgrade.