There is no guarantee that you will get the same workspace on a node. It will try, but a workspace can only be in use by 1 job at a time. So if you require a specific workspace, you have a few options:
Define a custom workspace with the ws step. But I think 2 jobs still can't use it at the same time. Stash/unstash the files you need to persist across nodes or stages set into a directory outside of the workspace to do what needs to be shared Use resource locking so that other jobs wait to access the workspace. Still not guaranteed to get the same workspace. Use resource locking combined with ws to specify a specific workspace and other jobs will wait for access to it. Specify a custom workspace and don't allow the job to run more than 1 build at a time. On Wednesday, October 25, 2017 at 5:15:39 PM UTC-6, Torsten Reinhard wrote: > > Hi, > > this pipeline sample fails, when started multiple times and running in > parallel at the same time. > Assigning a captured node again seems to be not enough - the workspace > isn´t matching than what will lead to very strange behaviour. > > import com.cloudbees.groovy.cps.NonCPS > > String buildNode > String buildNodeWS > > @NonCPS > assertWorkspaces(current, expected ) { > assert current == expected > } > > node() { > buildNode = env.NODE_NAME > buildNodeWS = env.WORKSPACE > echo "performing build on node ${buildNode} in ${buildNodeWS}" > } > > checkpoint("built") > node('sdp') { > echo "running on any node, currently it´s ${env.NODE_NAME}" > } > checkpoint("deployed") > > node( buildNode ) { > String currentWS = env.WORKSPACE > echo "running on ${buildNode} again - it´s ${env.NODE_NAME} in > ${currentWS}" > > assertWorkspaces(currentWS, buildNodeWS) > } > > Do I have to manage the workspace by myself - or is that a bug to be > reported? > > What do you think ? > > Torsten > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d39b50ba-6722-48be-aacf-fc5c06e0756b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.