Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-66351

( github repo name validation ) jobDSL configured github branch source complains of invalid GithubAppCredentials

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None

      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

       

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

          Andras created issue -
          Andras made changes -
          Description Original: To reproduce:

          1) create a GithubAppCredential in an init script
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    credentialsId(github-app-credentials)
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          New: To reproduce:

          1) create a GithubAppCredential in an init script
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          Andras made changes -
          Description Original: To reproduce:

          1) create a GithubAppCredential in an init script
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          New: To reproduce:

          1) create a GithubAppCredential in an init script
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          Andras made changes -
          Description Original: To reproduce:

          1) create a GithubAppCredential in an init script
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          New: update: *can only reproduce when the github repo url ends in .git*

          If this is an invalid url to provide for github branch source plugin, do you think showing a different error message at scan time would be feasible?

          original description follows: 

          To reproduce:

          1) create a GithubAppCredential in an init script
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          Andras made changes -
          Summary Original: jobDSL configured github branch source complains of invalid GithubAppCredentials New: ( github repo url validation ) jobDSL configured github branch source complains of invalid GithubAppCredentials
          Andras made changes -
          Description Original: update: *can only reproduce when the github repo url ends in .git*

          If this is an invalid url to provide for github branch source plugin, do you think showing a different error message at scan time would be feasible?

          original description follows: 

          To reproduce:

          1) create a GithubAppCredential in an init script
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          New: update: *can only reproduce when the github repo url ends in .git*

          If this is an invalid url 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 url when 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
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          Andras made changes -
          Description Original: update: *can only reproduce when the github repo url ends in .git*

          If this is an invalid url 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 url when 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
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          New: update: *can only reproduce when the github repo name ends 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 when 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
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          Andras made changes -
          Summary Original: ( github repo url validation ) jobDSL configured github branch source complains of invalid GithubAppCredentials New: ( github repo name validation ) jobDSL configured github branch source complains of invalid GithubAppCredentials
          Andras made changes -
          Description Original: update: *can only reproduce when the github repo name ends 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 when 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
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

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

          update2: github *allows repository names to end in .git* , and when that repository is private, it is possible the API doesnt differentiate between "no permissions" to access and "does not exist" - if that is the case, i'm not sure what kind of improvement can be made here?

          -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 when 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
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           
          Andras made changes -
          Description Original: update: *can only reproduce when the github repo name ends in .git*

          update2: github *allows repository names to end in .git* , and when that repository is private, it is possible the API doesnt differentiate between "no permissions" to access and "does not exist" - if that is the case, i'm not sure what kind of improvement can be made here?

          -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 when 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
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

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

          update2: github *allows repository names to end in .git* , and when that repository is private, it is possible the API doesnt differentiate between "no permissions to access repo" and "repo does not exist" - if that is the case, i'm not sure what kind of improvement can be made here

          -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 when 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
          {code:java}
          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)
          {code}
          2) configure a multibranch pipeline with a github branch source from a seed job
          {code:java}
          multibranchPipelineJob('foo') {
            branchSources {
              branchSource {
                source {
                  github {
                    id('foo')
                    credentialsId('github-app-credentials')
                    // ...
                  }
                }
              }
            }
          }
                    {code}
          3) created pipeline will fail to scan ( initial or subsequent scans ) the repository with the below exception:
          {code:java}
          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{code}
          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

           

            Unassigned Unassigned
            andlaz Andras
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: