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

ClassCastException in git plugin on GitHub branch scan

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • git-plugin
    • None
    • Jenkins 2.176.1 LTS release candidate
      GitHub Branch Source Plugin 2.5.3
      Git plugin 4.0 pre-release
      Git client plugin 3.0 pre-release

      Git plugin 4.0 pre-release reports a class cast exception when scanning in a multibranch pipeline definition for the hello-world-plugin.

      The stack trace is:

      Started by user Mark Waite
      [Sat May 25 13:03:00 MDT 2019] Starting branch indexing...
      13:03:00 Connecting to https://api.github.com using MarkEWaite/****** (MarkEWaite github username/password)
      Examining MarkEWaite/hello-world-plugin
      ERROR: [Sat May 25 13:03:01 MDT 2019] Could not fetch branches from source 8b33b746-db40-4839-901f-d94e4a4f3148
      java.lang.ClassCastException: org.jenkinsci.plugins.github_branch_source.GitHubSCMSourceContext cannot be cast to jenkins.plugins.git.GitSCMSourceContext
      	at jenkins.plugins.git.traits.PruneStaleBranchTrait.decorateContext(PruneStaleBranchTrait.java:54)
      	at jenkins.scm.api.trait.SCMSourceTrait.applyToContext(SCMSourceTrait.java:53)
      	at jenkins.scm.api.trait.SCMSourceContext.withTrait(SCMSourceContext.java:221)
      	at jenkins.scm.api.trait.SCMSourceContext.withTraits(SCMSourceContext.java:246)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:888)
      	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
      	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283)
      	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:634)
      	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
      	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164)
      	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1025)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)
      [Sat May 25 13:03:01 MDT 2019] Finished branch indexing. Indexing took 0.36 sec
      FATAL: Failed to recompute children of Hello World Plugin Folder ยป hello world pipeline (GitHub)
      java.lang.ClassCastException: org.jenkinsci.plugins.github_branch_source.GitHubSCMSourceContext cannot be cast to jenkins.plugins.git.GitSCMSourceContext
      	at jenkins.plugins.git.traits.PruneStaleBranchTrait.decorateContext(PruneStaleBranchTrait.java:54)
      	at jenkins.scm.api.trait.SCMSourceTrait.applyToContext(SCMSourceTrait.java:53)
      	at jenkins.scm.api.trait.SCMSourceContext.withTrait(SCMSourceContext.java:221)
      	at jenkins.scm.api.trait.SCMSourceContext.withTraits(SCMSourceContext.java:246)
      	at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:888)
      	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
      	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283)
      	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:634)
      	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
      	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164)
      	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1025)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)
      Finished: FAILURE
      

      Job definition is included as config.xml

      The code that is throwing that exception was added in git plugin commit 089a6ec as part of pull request 696. I suspect that more logic is needed in this line to check that the passed in SCMSourceContext is a GitSCMSourceContext before setting the pruneRefs value.

            markewaite Mark Waite
            markewaite Mark Waite
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: