jenkinsci / jenkinsci/subversion-plugin

[JENKINS-49069] Multibranch Pipeline project cannot copy scm.locations to new SubversionSCM in Jenkinsfile without cast to List<...>

Open
#1,450 0 comments 0 reactions 0 assignees View on GitHub
component:subversion-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
131
Forks
275
Avg merge
12h 4m
Merged PRs (30d)
6

Description

The cast seems redundant. I'm not sure if this affects other fields, but scm.locations is what I use. I need to do some checking out on the node, but with slightly different parameters.

The failing checkout step:

            checkout  changelog: false, scm: [$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: scm.locations, quietOperation: true, workspaceUpdater: [$class: 'UpdateWithCleanUpdater']]

 

Produces following error:

{{ java.lang.ClassCastException: hudson.scm.SubversionSCM.locations expects java.util.List but received class [Lhudson.scm.SubversionSCM$ModuleLocation;}}

{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:394)}}

{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:318)}}

{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:259)}}

{{ Caused: java.lang.IllegalArgumentException: Could not instantiate {excludedRegions=, quietOperation=true, workspaceUpdater={$class=UpdateWithCleanUpdater}, additionalCredentials=[], excludedUsers=, filterChangelog=false, excludedRevprop=, ignoreDirPropChanges=false, includedRegions=, locations=[Lhudson.scm.SubversionSCM$ModuleLocation;@​17f0e7d, excludedCommitMessages=} for SubversionSCM(locations: ModuleLocation(remote: String, credentialsId: String, local: String, depthOption: String, ignoreExternalsOption: boolean)[], workspaceUpdater: WorkspaceUpdater{CheckoutUpdater() | NoopUpdater() | UpdateUpdater() | UpdateWithCleanUpdater() | UpdateWithRevertUpdater()}, browser: SubversionRepositoryBrowser{Assembla(spaceName: String) | CollabNetSVN(url: String) | FishEyeSVN(url: String, rootModule: String) | Phabricator(url: String, repo: String) | RedmineRepositoryBrowser(repositoryId: String) | SVNWeb(url: String) | Sventon(url: String, repositoryInstance: String) | Sventon2(url: String, repositoryInstance: String) | ViewSVN(url: String) | WebSVN(url: String)}, excludedRegions: String, excludedUsers: String, excludedRevprop: String, excludedCommitMessages: String, includedRegions: String, ignoreDirPropChanges: boolean, filterChangelog: boolean, additionalCredentials: AdditionalCredentials(realm: String, credentialsId: String)[], quietOperation: boolean)}}

{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:264)}}

{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:380)}}

{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:318)}}

{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:259)}}

{{ at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:201)}}

{{ at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:205)}}

{{ at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:150)}}

{{ at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)}}

{{ 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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)}}

{{ at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)}}

{{ at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)}}

{{ at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)}}

{{ at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)}}

{{ at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)}}

{{ at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)}}

{{ at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)}}

{{ at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)}}

{{ at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:133)}}

{{ at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)}}

{{ at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)}}

{{ at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)}}

{{ at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)}}

{{ at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)}}

{{ at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)}}

 

Adding a cast to List<...> resolves the error:

            checkout  changelog: false, scm: [$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: scm.locations as java.util.List, quietOperation: true, workspaceUpdater: [$class: 'UpdateWithCleanUpdater']]

---
Originally reported by gl1koz3, imported from: Multibranch Pipeline project cannot copy scm.locations to new SubversionSCM in Jenkinsfile without cast to List<...>


  • status: Open
  • priority: Minor
  • component(s): subversion-plugin
  • resolution: Unresolved
  • votes: 3
  • watchers: 4
  • imported: 20251212-090250

Raw content of original issue

The cast seems redundant. I'm not sure if this affects other fields, but scm.locations is what I use. I need to do some checking out on the node, but with slightly different parameters.

The failing checkout step:
            checkout  changelog: false, scm: [$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: scm.locations, quietOperation: true, workspaceUpdater: [$class: 'UpdateWithCleanUpdater']]

 

Produces following error:

{{ java.lang.ClassCastException: hudson.scm.SubversionSCM.locations expects java.util.List<hudson.scm.SubversionSCM$ModuleLocation> but received class [Lhudson.scm.SubversionSCM$ModuleLocation;}}
{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:394)}}
{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:318)}}
{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:259)}}
{{ Caused: java.lang.IllegalArgumentException: Could not instantiate {excludedRegions=, quietOperation=true, workspaceUpdater={$class=UpdateWithCleanUpdater}, additionalCredentials=[], excludedUsers=, filterChangelog=false, excludedRevprop=, ignoreDirPropChanges=false, includedRegions=, locations=[Lhudson.scm.SubversionSCM$ModuleLocation;@17f0e7d, excludedCommitMessages=} for SubversionSCM(locations: ModuleLocation(remote: String, credentialsId: String, local: String, depthOption: String, ignoreExternalsOption: boolean)[], workspaceUpdater: WorkspaceUpdater{CheckoutUpdater() | NoopUpdater() | UpdateUpdater() | UpdateWithCleanUpdater() | UpdateWithRevertUpdater()}, browser: SubversionRepositoryBrowser{Assembla(spaceName: String) | CollabNetSVN(url: String) | FishEyeSVN(url: String, rootModule: String) | Phabricator(url: String, repo: String) | RedmineRepositoryBrowser(repositoryId: String) | SVNWeb(url: String) | Sventon(url: String, repositoryInstance: String) | Sventon2(url: String, repositoryInstance: String) | ViewSVN(url: String) | WebSVN(url: String)}, excludedRegions: String, excludedUsers: String, excludedRevprop: String, excludedCommitMessages: String, includedRegions: String, ignoreDirPropChanges: boolean, filterChangelog: boolean, additionalCredentials: AdditionalCredentials(realm: String, credentialsId: String)[], quietOperation: boolean)}}
{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:264)}}
{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:380)}}
{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:318)}}
{{ at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:259)}}
{{ at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:201)}}
{{ at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:205)}}
{{ at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:150)}}
{{ at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)}}
{{ 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.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)}}
{{ at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)}}
{{ at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)}}
{{ at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)}}
{{ at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)}}
{{ at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)}}
{{ at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)}}
{{ at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)}}
{{ at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)}}
{{ at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:133)}}
{{ at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)}}
{{ at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)}}
{{ at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)}}
{{ at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)}}
{{ at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)}}
{{ at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)}}

 

Adding a cast to List<...> resolves the error:

            checkout  changelog: false, scm: [$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: scm.locations as java.util.List<hudson.scm.SubversionSCM$ModuleLocation>, quietOperation: true, workspaceUpdater: [$class: 'UpdateWithCleanUpdater']]

environment

```
Windows 10 x64

Jenkins 2.100

latest plugins
```

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.