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

Declarative Pipeline serialization errors when XStreamPickle is used

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • None
    • Jenkins 2.32.2.6
      Declarative Pipeline 1.02

      While this block works on my local Jenkins it doesn't work on my company's internal Jenkins

      stage('Push to S3') {
        when {
          expression {
            def branch = env.BRANCH_NAME
            return branch == 'master' || branch == 'develop'
          }
        }
        steps {
          // Push to S3
        }
      }
      

          [JENKINS-42498] Declarative Pipeline serialization errors when XStreamPickle is used

          Andrew Bayer added a comment -

          So from the stacktrace, it looks coincidental that it's when that's failing - I believe the real serialization issue is in environment, which is still a bit odd, but I'll dig.

          Andrew Bayer added a comment - So from the stacktrace, it looks coincidental that it's when that's failing - I believe the real serialization issue is in environment , which is still a bit odd, but I'll dig.

          Andrew Bayer added a comment -

          Verified I can't reproduce this on 2.32.3...

          Andrew Bayer added a comment - Verified I can't reproduce this on 2.32.3...

          Andrew Bayer added a comment -

          So the problem is that CloudBees' proprietary Templates plugin ends up serializing Pipelines via XStream, which blacklists GStringImpl. The delegate for StepsBlock closures ends up being the ClosureModelTranslator for the entire build, which contains, among other things, possible GStringImpl instances, so...boom.

          Andrew Bayer added a comment - So the problem is that CloudBees' proprietary Templates plugin ends up serializing Pipelines via XStream, which blacklists GStringImpl . The delegate for StepsBlock closures ends up being the ClosureModelTranslator for the entire build, which contains, among other things, possible GStringImpl instances, so...boom.

          Andrew Bayer added a comment -

          danielbeck - the most effective way I can come up with to fix this would be to de-blacklist GStringImpl. Is that a viable possibility?

          Andrew Bayer added a comment - danielbeck - the most effective way I can come up with to fix this would be to de-blacklist GStringImpl . Is that a viable possibility?

          Andrew Bayer added a comment -

          Ok, I think I have a fix, now I need to come up with a test.

          Andrew Bayer added a comment - Ok, I think I have a fix, now I need to come up with a test.

          Andrew Bayer added a comment -

          Andrew Bayer added a comment - PR up at  https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/131

          Andrew Bayer added a comment -

          After initial review, I tried an alternate approach, which is up at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/132

          Andrew Bayer added a comment - After initial review, I tried an alternate approach, which is up at  https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/132

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/SerializationTest.java
          pipeline-model-definition/src/test/resources/serializationAgentGString.groovy
          pipeline-model-definition/src/test/resources/serializationAgentNestedGString.groovy
          pipeline-model-definition/src/test/resources/serializationEnvGString.groovy
          pipeline-model-definition/src/test/resources/serializationJobPropsGString.groovy
          pipeline-model-definition/src/test/resources/serializationLibrariesGString.groovy
          pipeline-model-definition/src/test/resources/serializationParametersGString.groovy
          pipeline-model-definition/src/test/resources/serializationTriggersGString.groovy
          pipeline-model-definition/src/test/resources/serializationWhenBranchGString.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/0a0b0d7a8a74f3a14ce2bbdbffe0e755708c168b
          Log:
          JENKINS-42498 Failure test for JENKINS-42498 serialization

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/SerializationTest.java pipeline-model-definition/src/test/resources/serializationAgentGString.groovy pipeline-model-definition/src/test/resources/serializationAgentNestedGString.groovy pipeline-model-definition/src/test/resources/serializationEnvGString.groovy pipeline-model-definition/src/test/resources/serializationJobPropsGString.groovy pipeline-model-definition/src/test/resources/serializationLibrariesGString.groovy pipeline-model-definition/src/test/resources/serializationParametersGString.groovy pipeline-model-definition/src/test/resources/serializationTriggersGString.groovy pipeline-model-definition/src/test/resources/serializationWhenBranchGString.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/0a0b0d7a8a74f3a14ce2bbdbffe0e755708c168b Log: JENKINS-42498 Failure test for JENKINS-42498 serialization

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/AbstractModelASTCodeBlock.java
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTArgumentList.java
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTNamedArgumentList.java
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPositionalArgumentList.java
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTSingleArgument.java
          pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWhenContent.java
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/Utils.groovy
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/StageConditionals.groovy
          pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
          pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/BranchConditional.java
          pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/EnvironmentConditional.java
          pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/ExpressionConditional.java
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/BranchConditionalScript.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/EnvironmentConditionalScript.groovy
          pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/ExpressionConditionalScript.groovy
          pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/SerializationTest.java
          pipeline-model-definition/src/test/resources/serializationWhenEnvGString.groovy
          http://jenkins-ci.org/commit/pipeline-model-definition-plugin/5cd7237782bf16c24ba4939cf4a8d3013f883ccc
          Log:
          [FIXED JENKINS-42498] Stop evaluating when conditions at runtime

          Pull the when conditions in by translating them from the AST model,
          which does require some evaluation of strings here and there, but
          avoids having any Closures in the Describables.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/AbstractModelASTCodeBlock.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTArgumentList.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTNamedArgumentList.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPositionalArgumentList.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTSingleArgument.java pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWhenContent.java pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/Utils.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/StageConditionals.groovy pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/BranchConditional.java pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/EnvironmentConditional.java pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/ExpressionConditional.java pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/BranchConditionalScript.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/EnvironmentConditionalScript.groovy pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/ExpressionConditionalScript.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/SerializationTest.java pipeline-model-definition/src/test/resources/serializationWhenEnvGString.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/5cd7237782bf16c24ba4939cf4a8d3013f883ccc Log: [FIXED JENKINS-42498] Stop evaluating when conditions at runtime Pull the when conditions in by translating them from the AST model, which does require some evaluation of strings here and there, but avoids having any Closures in the Describables.

          Liam Newman added a comment -

          Bulk closing resolved issues.

          Liam Newman added a comment - Bulk closing resolved issues.

            abayer Andrew Bayer
            mmccaskill Michael McCaskill
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: