I have a piece of code to list all files in the /tmp directory on two nodes, like so (scripted syntax):
stage('Demo') {
node('node1') {
println new File('/tmp/').listFiles().toList()
}
node('node2') {
println new File('/tmp/').listFiles().toList()
}
}
However, the results from both nodes are identical. It looks like the code is executed on the master, only the println function is executed on the 2 nodes.
The question is: is it true? and if so, how do I know if the code is executed on master or slaves?