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

NotSerializableException using declarative parameter buildSelector

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: copyartifact-plugin
    • Labels:
      None
    • Environment:
      Jenkins: 2.222.1
      Copy Artifact Plugin: 1.43.1
    • Similar Issues:

      Description

      Using the Jenkinsfile below as an example of a declarative pipeline with buildSelector as a parameter:

      pipeline {
          agent any
          parameters {
              buildSelector(defaultSelector: lastSuccessful(), description: 'Build Selector', name: 'BUILD_SELECTOR')
          }
          stages {
              stage('Test') {
                  steps {
                      copyArtifacts fingerprintArtifacts: true, projectName: 'TEST', selector: buildParameter('BUILD_SELECTOR')
                  }
              }
          }
      }

      The Jenkins job will fail with the following error in the logs (full stack trace attached):

      2020-04-04 06:34:24.037+0000 [id=302]	WARNING	o.j.p.w.cps.CpsThreadGroup#saveProgramIfPossible: program state save failed
      an exception which occurred:
      	in field hudson.plugins.copyartifact.BuildSelectorParameter.defaultSelector
      	in object hudson.plugins.copyartifact.BuildSelectorParameter@cae80c2
      	in field org.jenkinsci.plugins.pipeline.modeldefinition.model.Parameters.parameters
      	in object org.jenkinsci.plugins.pipeline.modeldefinition.model.Parameters@cae9042
      	in field org.jenkinsci.plugins.pipeline.modeldefinition.model.Root.parameters
      	in object org.jenkinsci.plugins.pipeline.modeldefinition.model.Root@3a89bd59
      	in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals
      	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@3bd8ad5b
      	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
      	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@27aee8de
      	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
      	in object com.cloudbees.groovy.cps.impl.TryBlockEnv@5b2d2915
      	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
      	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@75a332f6
      	in field com.cloudbees.groovy.cps.impl.CallEnv.caller
      	in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@570f35f2
      	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
      	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@4e440f3c
      	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
      	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@43b3619b
      	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
      	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@637efe56
      	in field com.cloudbees.groovy.cps.impl.CallEnv.caller
      	in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@5c1f8e4c
      	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
      	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@1862a28
      	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
      	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@59f8040d
      	in field com.cloudbees.groovy.cps.impl.CallEnv.caller
      	in object com.cloudbees.groovy.cps.impl.FunctionCallEnv@e7adb89
      	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
      	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@78865c91
      	in field com.cloudbees.groovy.cps.impl.ProxyEnv.parent
      	in object com.cloudbees.groovy.cps.impl.BlockScopeEnv@35eaa3e5
      	in field com.cloudbees.groovy.cps.impl.CpsClosureDef.capture
      	in object com.cloudbees.groovy.cps.impl.CpsClosureDef@e3560f9
      	in field com.cloudbees.groovy.cps.impl.CpsClosure.def
      	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@1ffc8194
      	in field groovy.lang.Closure.delegate
      	in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@7d4b25d3
      	in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
      	in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@2e560f1f
      	in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@2e560f1f
      Caused: java.io.NotSerializableException: hudson.plugins.copyartifact.StatusBuildSelector
       

        Attachments

          Activity

          rwmnz Rhys Meaclem created issue -
          Hide
          rwgrizzell Robert Grizzell added a comment -

          This bug is also affecting us as well.

          Show
          rwgrizzell Robert Grizzell added a comment - This bug is also affecting us as well.
          ikedam ikedam made changes -
          Field Original Value New Value
          Assignee ikedam [ ikedam ]
          ikedam ikedam made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Hide
          ikedam ikedam added a comment -

          This looks happen only when you use declarative pipelines.
          Please use scripted pipelines as a workaround for now.

          Show
          ikedam ikedam added a comment - This looks happen only when you use declarative pipelines. Please use scripted pipelines as a workaround for now.
          Hide
          ikedam ikedam added a comment -

          It's proposed to have BuildSelector implement Serializable (https://github.com/jenkinsci/copyartifact-plugin/pull/133).

          But I'm not sure it preserves compatibilities. (as far as I know, it should preserve compatibilities, but I'm not so sure).
          Copyartifact is an old plugin and some other plugins depends on BuildSelector. Incompatibility causes problems also in other plugins, and I'd like to go in a safer way making BuildSelectorParameter::defaultSelector transitive and storing string expression of BuildSelectorParameter::defaultSelector instead.

          Show
          ikedam ikedam added a comment - It's proposed to have BuildSelector implement Serializable ( https://github.com/jenkinsci/copyartifact-plugin/pull/133 ). But I'm not sure it preserves compatibilities. (as far as I know, it should preserve compatibilities, but I'm not so sure). Copyartifact is an old plugin and some other plugins depends on BuildSelector. Incompatibility causes problems also in other plugins, and I'd like to go in a safer way making BuildSelectorParameter::defaultSelector transitive and storing string expression of BuildSelectorParameter::defaultSelector instead.
          Hide
          macdrega Joerg Schwaerzler added a comment -

          As a workaround, using the properties step should work for declarative pipelines, too - like this:

          properties([...])
          pipeline {
              //...
          }
          
          Show
          macdrega Joerg Schwaerzler added a comment - As a workaround, using the properties step should work for declarative pipelines, too - like this: properties([...]) pipeline { //... }
          Show
          ikedam ikedam added a comment - https://github.com/jenkinsci/copyartifact-plugin/pull/136
          Hide
          ikedam ikedam added a comment -

          Fixed in copyartifact-1.46.

          Copyartifact-1.46 will be available in the update center.
          Please try that.

          Show
          ikedam ikedam added a comment - Fixed in copyartifact-1.46. Copyartifact-1.46 will be available in the update center. Please try that.
          ikedam ikedam made changes -
          Released As https://github.com/jenkinsci/copyartifact-plugin/blob/master/CHANGELOG.adoc#146
          Assignee ikedam [ ikedam ] Rhys Meaclem [ rwmnz ]
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Resolved [ 5 ]

            People

            Assignee:
            rwmnz Rhys Meaclem
            Reporter:
            rwmnz Rhys Meaclem
            Votes:
            6 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: