I have a Jenkins pipeline looking like this
stage 'build app'
build 'app-build'
stash 'app-stash'
stage 'build container'
unstash 'app-stash'
build 'container-build'
The builds app-build
and container-build
obtain new nodes from our Kubernetes system.
With stash I want to transfer the artifacts from app-build
to container-build
.
However when running this pipeline the following error occurs:
[Pipeline] stash
Required context class hudson.FilePath is missing
Perhaps you forgot to surround the code with a step that provides this, such as: node
[Pipeline] End of Pipeline
org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing
at org.jenkinsci.plugins.workflow.steps.StepDescriptor.checkContextAvailability(StepDescriptor.java:254)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:179)
I don't want to use node
in my pipeline since I only have one executor on my nodes.
Is it possible to use stash
without the node
directive?
Using build you're building an external job. However you cannot use 'stash' to copy things from one job to another.
You either need to archive artifacts inside 'app-build' and copy them using the aritfact copy plugin, or you have to move the content from 'app-build' into the pipeline itself. When doing that you'll have the node context required for the stash.
Btw.: Unstash needs a node context as well as it want to copy the files somewhere.