This job is not a bug reported, it is intended to highlight the way that Jenkins processes shell environment variables and the impact that has on P4Jenkins variables:
In the example below 3 different syncs are perfromed on 3 nodes at 3 different times. Waits occur till the end of all sync's then P4_CHANGELIST is output from each of those nodes from a shell or command prompt.
Note how P4_CHANGELIST changes over time because different nodes sync at '@now' at different times but at the end all nodes report the same changelist ID which does not match the value they synced to.
$ grep "NODE_NAME|P4_CHANGELIST|syncing files at change" console.txt | grep -v syncID
16:01:50 P4 Task: syncing files at change: 215144
16:01:56 NODE_NAME=Linux_Node1
16:01:56 P4_CHANGELIST=215144
16:01:56 NODE_NAME=Linux_Node2
16:01:56 P4_CHANGELIST=215144
16:01:56 NODE_NAME=Windows_Node1
16:01:56 P4_CHANGELIST=215144
16:02:10 P4 Task: syncing files at change: 215146 # Windows_Node1 Sync
16:02:15 NODE_NAME=Windows_Node1
16:02:15 P4_CHANGELIST=215146
16:02:30 P4 Task: syncing files at change: 215148 # Linux_Node2 Sync
16:03:10 P4 Task: syncing files at change: 215152 # Linux_Node1 Sync
16:03:14 NODE_NAME=Linux_Node1
16:03:14 P4_CHANGELIST=215152
16:03:25 NODE_NAME=Linux_Node1
16:03:25 P4_CHANGELIST=215152
16:04:34 NODE_NAME=Linux_Node2
16:04:34 P4_CHANGELIST=215152
16:06:56 NODE_NAME=Windows_Node1
16:06:56 P4_CHANGELIST=215152
**
Each node exceutes commands in a parrallel block in a function:
def call(Map config) {pipeline { agent any options { skipDefaultCheckout() } stages { stage('Parallel Stage') { parallel { stage('Windows_Node1') { agent { label "Windows_Node1" } stages { stage('Windows_Node1 build') { steps { sleep 10 bat 'set' SyncMyWorkspace(config) bat 'set' } } stage('Windows_Node1 Test') { steps { sleep 1000 bat 'set' } } } } stage('Linux_Node1') { agent { label "Linux_Node1" } stages { stage('Linux_Node1 build') { steps { sh 'env' sleep 60 SyncMyWorkspace(config) sh 'env' } } stage('Linux_Node1 Test') { steps { sleep 120 sh 'env' } } } } stage('Linux_Node1') { agent { label "Linux_Node2" } stages { stage('Linux_Node2 build') { steps { sh 'env' sleep 120 SyncMyWorkspace(config) } } stage('Linux_Node2 Test') { steps { sleep 60 sh 'env' } } } } } } } }}