Description

Hello here!

I am currently trying to build a Declarative Pipeline with a conditional stage.

The condition should be triggered by the result of a shell command on my project (following the pipeline-as-glue pattern: my developer needs to know this on another environments as Jenkins, so using a script).

This shell command respond the string "false" or "true".

Based on this feedback, then I run the stage or not.

After some digging, it appears calling a "sh" step within an expression is no longer working: it throws the following exception "

java.lang.IllegalStateException: Can't send a remote FilePath to a different remote channel

Still can't reproduce this in any other environment. Fun! It seems the real underlying problem is like JENKINS-30864 but I can't reproduce it even in your environment outside of a declarative pipeline yet...

Andrew Bayer
added a comment - 2017-11-24 16:24 - edited Still can't reproduce this in any other environment. Fun! It seems the real underlying problem is like JENKINS-30864 but I can't reproduce it even in your environment outside of a declarative pipeline yet...

Damien Duportal
added a comment - 2017-11-24 17:01 Same on my side:
Cannot reproduce on a 2.72.3 LTS with Blue Ocean installed, plugins to latest.
On my "buggy" environment, same error when loading from a shared library

This shouldn't really matter, in truth - I believe we actually
regenerate the whole Root object from scratch on resume, though I
could be misremembering. Regardless, even having the when expression
closure be transient, the durability test (with when expressions
added) still works right.

As to why we need to do this in the first place? Because something
weird could be out there trying to some non-standard serialization of
Describables. Ok, spoiler, there definitely is such a thing, and it
does a straight XStream serialization of every Describable. But we use
Describables as more than just UI config stuff - we use them for
syntax validation and such for our internal extension points, like
when conditions. And if that XStream serialization of a when
expression with a sh step kicks in, well, all hell breaks loose. This
works around that.

SCM/JIRA link daemon
added a comment - 2017-11-27 21:02 Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ASTParserUtils.groovy
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/ExpressionConditional.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/DurabilityTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WhenStageTest.java
pipeline-model-definition/src/test/resources/whenExprDurableTask.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/f601a676095b65b559a88b8374532cd9d4b074ac
Log:
[FIXED JENKINS-48209] Prevent serialization of when expression closure
This shouldn't really matter, in truth - I believe we actually
regenerate the whole Root object from scratch on resume, though I
could be misremembering. Regardless, even having the when expression
closure be transient, the durability test (with when expressions
added) still works right.
As to why we need to do this in the first place? Because something
weird could be out there trying to some non-standard serialization of
Describables. Ok, spoiler, there definitely is such a thing, and it
does a straight XStream serialization of every Describable. But we use
Describables as more than just UI config stuff - we use them for
syntax validation and such for our internal extension points, like
when conditions. And if that XStream serialization of a when
expression with a sh step kicks in, well, all hell breaks loose. This
works around that.