title: Groovy StreamingTemplateEngine gives error with withCredentials function
body: <p>I created the Jenkins pipeline which calls below function... It creates a Template variable with StreamingTemplateEngine object... But it gives an error</p>
  
  <pre class="lang-groovy prettyprint-override"><code>def call() {
      def name = "abc"
      def binding = [
          firstname: "Grace",
          lastname: "Hopper",
      ]
  
      def text = 'Dear &lt;% out.print firstname %&gt; ${lastname}'
      def template = new groovy.text.StreamingTemplateEngine().createTemplate(text)
  
      print template.make(binding)
  
      def response = template.make(binding)
  
      withCredentials([string(credentialsId: 'Token', variable: 'TOKEN')]) {
          println("test")
          println(response)
      }
  }
  </code></pre>
  
  <p>Above code prints response successfully first time but at the end it gives below error</p>
  
  <pre><code>an exception which occurred:
          in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals
          in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@3678d955
          in field com.cloudbees.groovy.cps.impl.CpsClosureDef.capture
          in object com.cloudbees.groovy.cps.impl.CpsClosureDef@23a3d63c
          in field com.cloudbees.groovy.cps.impl.CpsClosure.def
          in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@6d8ad313
          in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
          in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@76f2b368
          in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@76f2b368
  Caused: java.io.NotSerializableException: groovy.text.StreamingTemplateEngine$StreamingTemplate
  </code></pre>
  
  <p>If I remove withCredentials function then it works fine.</p>