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

Old syntax not honored for explicit single required parameter taking struct

XMLWordPrintable

      egutierrez running plugin-compat-tester found that org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapperWorkflowTest.symbolWithTargetLocation fails when you update

      diff --git a/pom.xml b/pom.xml
      index 32c873b..6dd604e 100644
      --- a/pom.xml
      +++ b/pom.xml
      @@ -115,7 +115,7 @@
               <dependency>
                   <groupId>org.jenkins-ci.plugins.workflow</groupId>
                   <artifactId>workflow-cps</artifactId>
      -            <version>2.10</version>
      +            <version>2.14</version>
                   <scope>test</scope>
               </dependency>
               <dependency>
      

      with this kind of exception:

      java.lang.UnsupportedOperationException: must specify $class with an implementation of interface java.util.List
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:442)
      

      As of JENKINS-29711 this syntax is deprecated—the managedFiles: can be omitted—but for compatibility we need to continue supporting the old syntax. The workaround is to update the test to the new syntax:

      diff --git a/src/test/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapperWorkflowTest.java b/src/test/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapperWorkflowTest.java
      index b4790b2..da9e64e 100644
      --- a/src/test/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapperWorkflowTest.java
      +++ b/src/test/java/org/jenkinsci/plugins/configfiles/buildwrapper/ConfigFileBuildWrapperWorkflowTest.java
      @@ -116,7 +116,7 @@ public class ConfigFileBuildWrapperWorkflowTest {
                       WorkflowJob p = story.j.jenkins.createProject(WorkflowJob.class, "p");
                       p.setDefinition(new CpsFlowDefinition(""
                               + "node {\n"
      -                        + "  configFileProvider(managedFiles: [configFile(fileId: '" + createConfig().id + "', targetLocation: 'myfile.txt')]) {sh 'cat myfile.txt'}\n"
      +                        + "  configFileProvider([configFile(fileId: '" + createConfig().id + "', targetLocation: 'myfile.txt')]) {sh 'cat myfile.txt'}\n"
                               + "}", true));
                       WorkflowRun b = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
                       story.j.assertLogContains("some content", b);
      

            abayer Andrew Bayer
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: