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

GString kept unevaluated as long as StepDescriptor.newInstance (was: Pipeline build fails with serialization error when using string interpolation)

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None
    • Jenkins 2.57

      I get the following error for my Pipeline jobs after upgrading from 2.56 to 2.57 (also updated a bunch of plugins, so I can't be certain that the core upgrade is the culprit). See also the comment https://issues.jenkins-ci.org/browse/JENKINS-42524?focusedCommentId=297258&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-297258, which seems to be the exact same issue I'm having.

      java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage$Tag#actions for class org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage$Tag
      	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
      	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
      	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
      	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
      	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
      	at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:82)
      	at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
      	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1026)
      	at com.thoughtworks.xstream.XStream.marshal(XStream.java:1015)
      	at com.thoughtworks.xstream.XStream.toXML(XStream.java:988)
      	at hudson.XmlFile.write(XmlFile.java:171)
      	at org.jenkinsci.plugins.workflow.support.storage.SimpleXStreamFlowNodeStorage.saveActions(SimpleXStreamFlowNodeStorage.java:111)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.saveActions(CpsFlowExecution.java:918)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode.save(FlowNode.java:380)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode.persistSafe(FlowNode.java:386)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode.access$100(FlowNode.java:61)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:346)
      	at org.jenkinsci.plugins.workflow.graph.FlowNode$1.add(FlowNode.java:336)
      	at java.util.AbstractList.add(AbstractList.java:108)
      	at hudson.model.Actionable.addAction(Actionable.java:152)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:897)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1110)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$3.run(CpsThreadGroup.java:402)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:35)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.lang.RuntimeException: Failed to serialize org.jenkinsci.plugins.workflow.cps.actions.ArgumentsActionImpl#arguments for class org.jenkinsci.plugins.workflow.cps.actions.ArgumentsActionImpl
      	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:256)
      	at hudson.util.RobustReflectionConverter$2.visit(RobustReflectionConverter.java:224)
      	at com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider.visitSerializableFields(PureJavaReflectionProvider.java:138)
      	at hudson.util.RobustReflectionConverter.doMarshal(RobustReflectionConverter.java:209)
      	at hudson.util.RobustReflectionConverter.marshal(RobustReflectionConverter.java:150)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
      	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
      	at com.thoughtworks.xstream.converters.collections.ArrayConverter.marshal(ArrayConverter.java:45)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
      	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
      	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
      	... 33 more
      Caused by: java.lang.UnsupportedOperationException: Refusing to marshal org.codehaus.groovy.runtime.GStringImpl for security reasons
      	at hudson.util.XStream2$BlacklistedTypesConverter.marshal(XStream2.java:452)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
      	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
      	at com.thoughtworks.xstream.converters.collections.CollectionConverter.marshal(CollectionConverter.java:74)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:43)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:88)
      	at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.writeItem(AbstractCollectionConverter.java:64)
      	at com.thoughtworks.xstream.converters.collections.MapConverter.marshal(MapConverter.java:79)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      	at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:58)
      	at com.thoughtworks.xstream.core.AbstractReferenceMarshaller$1.convertAnother(AbstractReferenceMarshaller.java:84)
      	at hudson.util.RobustReflectionConverter.marshallField(RobustReflectionConverter.java:265)
      	at hudson.util.RobustReflectionConverter$2.writeField(RobustReflectionConverter.java:252)
      

          [JENKINS-43934] GString kept unevaluated as long as StepDescriptor.newInstance (was: Pipeline build fails with serialization error when using string interpolation)

          Emil Styrke created issue -

          Emil Styrke added a comment -

          Replacing all string interpolations ("foo ${variable} bar") with concatenations ("foo" + variable + "bar") in the Jenkinsfile seems to work around the problem.

          Emil Styrke added a comment - Replacing all string interpolations ("foo ${variable} bar") with concatenations ("foo" + variable + "bar") in the Jenkinsfile seems to work around the problem.
          Emil Styrke made changes -
          Summary Original: Pipeline build fails with serialization error New: Pipeline build fails with serialization error when using string interpolation
          Emil Styrke made changes -
          Component/s New: core [ 15593 ]

          estyrke does this affect non Jenkinsfile based jobs like legacy pipeline jobs or legacy jobs in general?

          Goffredo Marocchi added a comment - estyrke does this affect non Jenkinsfile based jobs like legacy pipeline jobs or legacy jobs in general?

          Emil Styrke added a comment -

          I have not tested, but I'm not sure how to test that. The error occurs because of script security issues (using Groovy string interpolation) with the Jenkinsfile, as far as I can see.

          None of my legacy jobs use Groovy scripts.

          Emil Styrke added a comment - I have not tested, but I'm not sure how to test that. The error occurs because of script security issues (using Groovy string interpolation) with the Jenkinsfile, as far as I can see. None of my legacy jobs use Groovy scripts.

          Sean Scoggins added a comment -

          I was able to work around this by explicitly converting from gstring to string, like this

          "a string with a ${variable}".toString()

          in my pipeline script.

          Sean Scoggins added a comment - I was able to work around this by explicitly converting from gstring to string, like this "a string with a ${variable}".toString() in my pipeline script.
          Jesse Glick made changes -
          Link New: This issue relates to JENKINS-42524 [ JENKINS-42524 ]

          Jesse Glick added a comment -

          Most likely due to a plugin update rather than core update. Anyone know how to reproduce from scratch?

          Jesse Glick added a comment - Most likely due to a plugin update rather than core update. Anyone know how to reproduce from scratch?
          Jesse Glick made changes -
          Component/s Original: core [ 15593 ]

            jglick Jesse Glick
            estyrke Emil Styrke
            Votes:
            2 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: