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

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

              Created:
              Updated: