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

Git Publisher (tagging) can't work with multipe SCM (ClassCastException: org.jenkinsci.plugins.multiplescms.MultiSCM cannot be cast to hudson.plugins.git.GitSCM)

      when using multiple SCM plugin together with Git Publisher the git publisher shows and ERROR message:
      (can we use for "Target remote name" the name specified in SCM?

      Status Code: 500

      Exception:
      Stacktrace:
      java.lang.ClassCastException: org.jenkinsci.plugins.multiplescms.MultiSCM cannot be cast to hudson.plugins.git.GitSCM
      at hudson.plugins.git.GitPublisher$DescriptorImpl.doCheckRemote(GitPublisher.java:424)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:288)
      at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:151)
      at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:90)
      at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111)
      at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
      at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241)
      at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
      at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241)
      at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
      at org.kohsuke.stapler.MetaClass$6.doDispatch(MetaClass.java:241)
      at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
      at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:574)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:659)
      at org.kohsuke.stapler.Stapler.invoke(Stapler.java:488)
      at org.kohsuke.stapler.Stapler.service(Stapler.java:162)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:45)
      at winstone.ServletConfiguration.execute(ServletConfiguration.java:248)
      at winstone.RequestDispatcher.forward(RequestDispatcher.java:333)
      at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:376)
      at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:95)
      at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:87)
      at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
      at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
      at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:47)
      at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
      at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
      at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:166)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:173)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at jenkins.security.ApiTokenFilter.doFilter(ApiTokenFilter.java:63)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
      at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:66)
      at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
      at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
      at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
      at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
      at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
      at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
      at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
      at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
      at winstone.RequestDispatcher.forward(RequestDispatcher.java:331)
      at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:215)
      at winstone.RequestHandlerThread.run(RequestHandlerThread.java:138)
      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)

          [JENKINS-13779] Git Publisher (tagging) can't work with multipe SCM (ClassCastException: org.jenkinsci.plugins.multiplescms.MultiSCM cannot be cast to hudson.plugins.git.GitSCM)

          Ajith Thampi added a comment -

          Any update on this fix? I am facing the exact same issue with MultiSCM.

          Ajith Thampi added a comment - Any update on this fix? I am facing the exact same issue with MultiSCM.

          Chris Chou added a comment -

          Any help with this? I tried applying the patch to the most recent version of git plugin but unfortunately it failed.

          Chris Chou added a comment - Any help with this? I tried applying the patch to the most recent version of git plugin but unfortunately it failed.

          Eyal David added a comment - - edited

          Hi Is there a chance that this bug will be fixed ?

          Eyal David added a comment - - edited Hi Is there a chance that this bug will be fixed ?

          I am also interested in a fix... But I assume, as it hasn't been fixed the past 3 years nothing will happen unfortunately! Bummer. Generally I took a quick look at the patch provided by Martin Hubert. The idea is to add a simple:

          if(scm instanceof MultiSCM) {
             for(SCM multiScm : ((MultiSCM)scm).getConfiguredSCMs()) {
                if(multiScm instanceof GitSCM)
                   oldPerform((GitSCM) multiScm, build, launcher, listener);
             ...
          else if(scm instanceof GitSCM)
             return oldPerform((GitSCM) scm, build, launcher, listener);
          else return false;
          

          (stripping a little logic for "success" management) to the current perform method... It would be great if you could provide such a patch.

          Kristian Kraljic added a comment - I am also interested in a fix... But I assume, as it hasn't been fixed the past 3 years nothing will happen unfortunately! Bummer. Generally I took a quick look at the patch provided by Martin Hubert. The idea is to add a simple: if (scm instanceof MultiSCM) { for (SCM multiScm : ((MultiSCM)scm).getConfiguredSCMs()) { if (multiScm instanceof GitSCM) oldPerform((GitSCM) multiScm, build, launcher, listener); ... else if (scm instanceof GitSCM) return oldPerform((GitSCM) scm, build, launcher, listener); else return false ; (stripping a little logic for "success" management) to the current perform method... It would be great if you could provide such a patch.

          Brantone added a comment -

          Brantone added a comment - Potential fix would be similar to https://github.com/jenkinsci/multiple-scms-plugin/pull/9

          Jacob Keller added a comment - - edited

          So the problem is that we can't generically support each type of SCM wrapper, and I don't think the maintainer wants to put unnecessary dependency on plugins which aren't required to use Git..?

          Is there a way to optionally add dependency without requiring they all be installed?

          Jacob Keller added a comment - - edited So the problem is that we can't generically support each type of SCM wrapper, and I don't think the maintainer wants to put unnecessary dependency on plugins which aren't required to use Git..? Is there a way to optionally add dependency without requiring they all be installed?

          Will Saxon added a comment -

          I was looking at extending something the other day, and the docs said you can a) add the plugin to the pom.xml and specify <optional>true</optional> on it, and b) use the optional=true modifier on the @Extension attribute if appropriate.

          Will Saxon added a comment - I was looking at extending something the other day, and the docs said you can a) add the plugin to the pom.xml and specify <optional>true</optional> on it, and b) use the optional=true modifier on the @Extension attribute if appropriate.

          Jacob Keller added a comment -

          Ok. That would help. But what if I'm not adding an extention point, just trying to use a class, ie: I need to be able to check if the SCM is a multi-scm? I don't know if that is reasonably doable or not...

          Jacob Keller added a comment - Ok. That would help. But what if I'm not adding an extention point, just trying to use a class, ie: I need to be able to check if the SCM is a multi-scm? I don't know if that is reasonably doable or not...

          Suggest that you migrate to Pipeline plugin, which offers a supported way of checking out from multiple scms
          https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin

          Craig Rodrigues added a comment - Suggest that you migrate to Pipeline plugin, which offers a supported way of checking out from multiple scms https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin

          rodrigc, Is there any support for pushing in pipeline? I do not see that on https://jenkins.io/doc/pipeline/steps/ for git or workflow-scm-step. In case users are expected to run that from shell, I do not think this justify as closing reason since used could do that with freestyle as well (multiple SCMs + git push from shell). Consuming credentials from Jenkins is one problem I can see.

          Oliver Gondža added a comment - rodrigc , Is there any support for pushing in pipeline? I do not see that on https://jenkins.io/doc/pipeline/steps/ for git or workflow-scm-step. In case users are expected to run that from shell, I do not think this justify as closing reason since used could do that with freestyle as well (multiple SCMs + git push from shell). Consuming credentials from Jenkins is one problem I can see.

            Unassigned Unassigned
            casey1911 Stanislav Jursky
            Votes:
            22 Vote for this issue
            Watchers:
            26 Start watching this issue

              Created:
              Updated: