jenkinsci / jenkinsci/github-branch-source-plugin

[JENKINS-66351] ( github repo name validation ) jobDSL configured github branch source complains of invalid GithubAppCredentials

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

Description

update: can only reproduce when the github repo name ends in .git

update2: github does not allow repository names to end in .git

**This happens because i'm parsing it out of a github url that ends in  .git. If this is an invalid repo name to provide for github branch source plugin, do you think showing a different error message at scan time would be feasible? what happens to the repo name whe-n the branch source is configured via stapler/the ui rather than jobdsl?-

original description follows: 

To reproduce:

1) create a GithubAppCredential in an init script

import hudson.util.Secret

import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.domains.*
import org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials

GitHubAppCredentials githubAppCredentials = new GitHubAppCredentials(
CredentialsScope.GLOBAL,
"github-app-credentials",
"github-app-credentials",
secrets["appId"],
Secret.fromString(secrets["privateKey"]))

SystemCredentialsProvider.getInstance().getStore().addCredentials(Domain.global(), (Credentials) githubAppCredentials)


2) configure a multibranch pipeline with a github branch source from a seed job

multibranchPipelineJob('foo') {

branchSources {
branchSource {
source {
github {
id('foo')
credentialsId('github-app-credentials')
repoOwner('my')
repository('repo.git')
// ...
}
}
}
}
}

3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:

Started

[Tue Aug 10 03:24:59 UTC 2021] Starting branch indexing...
03:24:59 Connecting to https://api.github.com using github-app-credentials
ERROR: [Tue Aug 10 03:24:59 UTC 2021] Could not update folder level actions from source foo
[Tue Aug 10 03:24:59 UTC 2021] Finished branch indexing. Indexing took 0.36 sec
FATAL: Invalid scan credentials when using github-app-credentials to connect to my/repo.git on https://api.github.com
Finished: FAILURE

4) go to configure page of pipeline, click save without any change to any of the fields

5) created pipeline will scan the repository without issue

 

---
Originally reported by andlaz, imported from: ( github repo name validation ) jobDSL configured github branch source complains of invalid GithubAppCredentials


  • status: Open
  • priority: Minor
  • component(s): github-branch-source-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 2025-12-02

Raw content of original issue

update: can only reproduce when the github repo name ends in .git

update2: github does not allow repository names to end in .git

**This happens because i'm parsing it out of a github url that ends in  .git. If this is an invalid repo name to provide for github branch source plugin, do you think showing a different error message at scan time would be feasible? what happens to the repo name whe-n the branch source is configured via stapler/the ui rather than jobdsl?-

original description follows: 

To reproduce:

1) create a GithubAppCredential in an init script



import hudson.util.Secret

import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.domains.*
import org.jenkinsci.plugins.github_branch_source.GitHubAppCredentials

GitHubAppCredentials githubAppCredentials = new GitHubAppCredentials(
CredentialsScope.GLOBAL,
"github-app-credentials",
"github-app-credentials",
secrets["appId"],
Secret.fromString(secrets["privateKey"]))

SystemCredentialsProvider.getInstance().getStore().addCredentials(Domain.global(), (Credentials) githubAppCredentials)



2) configure a multibranch pipeline with a github branch source from a seed job



multibranchPipelineJob('foo') {

branchSources {
branchSource {
source {
github {
id('foo')
credentialsId('github-app-credentials')
repoOwner('my')
repository('repo.git')
// ...
}
}
}
}
}


3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:



Started

[Tue Aug 10 03:24:59 UTC 2021] Starting branch indexing...
03:24:59 Connecting to https://api.github.com using github-app-credentials
ERROR: [Tue Aug 10 03:24:59 UTC 2021] Could not update folder level actions from source foo
[Tue Aug 10 03:24:59 UTC 2021] Finished branch indexing. Indexing took 0.36 sec
FATAL: Invalid scan credentials when using github-app-credentials to connect to my/repo.git on https://api.github.com
Finished: FAILURE


4) go to configure page of pipeline, click save without any change to any of the fields

5) created pipeline will scan the repository without issue

 

environment

```
Running Jenkins via the kubernetes operator 0.6.0

Jenkins: 2.289.3

OS: Linux - 4.19.0-16-amd64

---

sshd:3.0.3

basic-branch-build-strategies:1.3.2

github-api:1.123

ssh-credentials:1.19

sse-gateway:1.24

blueocean-pipeline-editor:1.24.8

pipeline-stage-tags-metadata:1.9.1

plain-credentials:1.7

token-macro:266.v44a80cf277fd

jquery3-api:3.6.0-2

script-security:1.78

blueocean-config:1.24.8

blueocean-display-url:2.4.1

workflow-step-api:2.24

blueocean-jwt:1.24.8

bootstrap5-api:5.1.0-1

github-branch-source:2.11.2

workflow-cps:2.93

popper-api:1.16.1-2

jdk-tool:1.0

command-launcher:1.2

pipeline-stage-view:2.19

authentication-tokens:1.4

blueocean-autofavorite:1.2.4

handlebars:3.0.8

blueocean-rest:1.24.8

github-checks:1.0.13

blueocean-bitbucket-pipeline:1.24.8

blueocean:1.24.7

blueocean-events:1.24.8

workflow-support:3.8

pubsub-light:1.16

google-login:1.6

github-app-kubernetes-credentials:0.0.1

matrix-auth:2.6.7

git:4.8.1

pipeline-milestone-step:1.3.2

bouncycastle-api:2.21

pipeline-model-api:1.9.1

blueocean-web:1.24.8

apache-httpcomponents-client-4-api:4.5.13-1.0

blueocean-i18n:1.24.8

variant:1.4

credentials-binding:1.27

blueocean-pipeline-api-impl:1.24.8

credentials:2.5

jenkins-design-language:1.24.8

trilead-api:1.0.13

blueocean-pipeline-scm-api:1.24.8

metrics:4.0.2.8

workflow-api:2.46

blueocean-personalization:1.24.8

checks-api:1.7.2

durable-task:1.38

github:1.33.1

htmlpublisher:1.25

matrix-project:1.19

pipeline-graph-analysis:1.11

job-dsl:1.77

workflow-durable-task-step:2.39

display-url-api:2.3.5

favorite:2.3.3

workflow-job:2.41

pipeline-build-step:2.15

kubernetes:1.30.1

blueocean-rest-impl:1.24.8

blueocean-git-pipeline:1.24.8

kubernetes-credentials:0.9.0

blueocean-github-pipeline:1.24.8

blueocean-commons:1.24.8

lockable-resources:2.11

git-client:3.9.0

data-tables-api:1.10.25-3

jsch:0.1.55.2

pipeline-model-definition:1.9.1

git-server:1.9

momentjs:1.1.1

workflow-multibranch:2.26

blueocean-core-js:1.24.8

pipeline-stage-step:2.5

timestamper:1.13

snakeyaml-api:1.29.1

cloudbees-bitbucket-branch-source:2.9.10

mailer:1.34

bootstrap4-api:4.6.0-3

blueocean-dashboard:1.24.8

copyartifact:1.39

pipeline-input-step:2.12

pipeline-model-extensions:1.9.1

workflow-cps-global-lib:2.21

ace-editor:1.1

forensics-api:1.3.0

workflow-basic-steps:2.23

analysis-model-api:10.3.0

antisamy-markup-formatter:2.1

plugin-util-api:2.4.0

jackson2-api:2.12.4

font-awesome-api:5.15.3-4

junit:1.52

jjwt-api:0.11.2-9.c8b45b8bb173

structs:1.23

caffeine-api:2.9.1-23.v51c4e2c879c8

popper2-api:2.9.3-1

kubernetes-credentials-provider:0.20

echarts-api:5.1.2-8

configuration-as-code:1.51

okhttp-api:3.14.9

cloudbees-folder:6.16

pipeline-rest-api:2.19

warnings-ng:9.4.0

workflow-aggregator:2.6

scm-api:2.6.5

workflow-scm-step:2.13

handy-uri-templates-2-api:2.1.8-1.0

branch-api:2.6.5

kubernetes-client-api:5.4.1

Result: [Plugin:sshd, Plugin:basic-branch-build-strategies, Plugin:github-api, Plugin:ssh-credentials, Plugin:sse-gateway, Plugin:blueocean-pipeline-editor, Plugin:pipeline-stage-tags-metadata, Plugin:plain-credentials, Plugin:token-macro, Plugin:jquery3-api, Plugin:script-security, Plugin:blueocean-config, Plugin:blueocean-display-url, Plugin:workflow-step-api, Plugin:blueocean-jwt, Plugin:bootstrap5-api, Plugin:github-branch-source, Plugin:workflow-cps, Plugin:popper-api, Plugin:jdk-tool, Plugin:command-launcher, Plugin:pipeline-stage-view, Plugin:authentication-tokens, Plugin:blueocean-autofavorite, Plugin:handlebars, Plugin:blueocean-rest, Plugin:github-checks, Plugin:blueocean-bitbucket-pipeline, Plugin:blueocean, Plugin:blueocean-events, Plugin:workflow-support, Plugin:pubsub-light, Plugin:google-login, Plugin:github-app-kubernetes-credentials, Plugin:matrix-auth, Plugin:git, Plugin:pipeline-milestone-step, Plugin:bouncycastle-api, Plugin:pipeline-model-api, Plugin:blueocean-web, Plugin:apache-httpcomponents-client-4-api, Plugin:blueocean-i18n, Plugin:variant, Plugin:credentials-binding, Plugin:blueocean-pipeline-api-impl, Plugin:credentials, Plugin:jenkins-design-language, Plugin:trilead-api, Plugin:blueocean-pipeline-scm-api, Plugin:metrics, Plugin:workflow-api, Plugin:blueocean-personalization, Plugin:checks-api, Plugin:durable-task, Plugin:github, Plugin:htmlpublisher, Plugin:matrix-project, Plugin:pipeline-graph-analysis, Plugin:job-dsl, Plugin:workflow-durable-task-step, Plugin:display-url-api, Plugin:favorite, Plugin:workflow-job, Plugin:pipeline-build-step, Plugin:kubernetes, Plugin:blueocean-rest-impl, Plugin:blueocean-git-pipeline, Plugin:kubernetes-credentials, Plugin:blueocean-github-pipeline, Plugin:blueocean-commons, Plugin:lockable-resources, Plugin:git-client, Plugin:data-tables-api, Plugin:jsch, Plugin:pipeline-model-definition, Plugin:git-server, Plugin:momentjs, Plugin:workflow-multibranch, Plugin:blueocean-core-js, Plugin:pipeline-stage-step, Plugin:timestamper, Plugin:snakeyaml-api, Plugin:cloudbees-bitbucket-branch-source, Plugin:mailer, Plugin:bootstrap4-api, Plugin:blueocean-dashboard, Plugin:copyartifact, Plugin:pipeline-input-step, Plugin:pipeline-model-extensions, Plugin:workflow-cps-global-lib, Plugin:ace-editor, Plugin:forensics-api, Plugin:workflow-basic-steps, Plugin:analysis-model-api, Plugin:antisamy-markup-formatter, Plugin:plugin-util-api, Plugin:jackson2-api, Plugin:font-awesome-api, Plugin:junit, Plugin:jjwt-api, Plugin:structs, Plugin:caffeine-api, Plugin:popper2-api, Plugin:kubernetes-credentials-provider, Plugin:echarts-api, Plugin:configuration-as-code, Plugin:okhttp-api, Plugin:cloudbees-folder, Plugin:pipeline-rest-api, Plugin:warnings-ng, Plugin:workflow-aggregator, Plugin:scm-api, Plugin:workflow-scm-step, Plugin:handy-uri-templates-2-api, Plugin:branch-api, Plugin:kubernetes-client-api]
```

2 attachments

- [image-2021-08-11-15-45-39-228.png](https://issues.jenkins.io/secure/attachment/55356/image-2021-08-11-15-45-39-228.png)
> ![image-2021-08-11-15-45-39-228.png](https://issues.jenkins.io/secure/attachment/55356/image-2021-08-11-15-45-39-228.png)
- [image-2023-08-22-14-40-50-086.png](https://issues.jenkins.io/secure/attachment/61043/image-2023-08-22-14-40-50-086.png)
> ![image-2023-08-22-14-40-50-086.png](https://issues.jenkins.io/secure/attachment/61043/image-2023-08-22-14-40-50-086.png)

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.