When enabling concurrent builds on a job and building the job multiple times simultaneous through the jenkins-cli or ssh the number of builds does not reflect the number of build requests and build details of an already building job might leak to a new connection.
Example:
In Jenkins i have set up my master node to have 10 executors and i have created a job with concurrent builds enabled with a shell script which does the following:
Jenkins
echo "Hello SSH" echo "Sleep $BUILD_NUMBER" sleep 10 echo "Awake $BUILD_NUMBER"
And a shell script that fires of that jenkins job 5 times:
test_jenkins.sh
#!/bin/bash for i in {1..5} do ssh -p 8022 localhost build some_project -v -s -w & done
Then Jenkins will spawn 2 or 3 jobs instead of 5 and give the output of a job sometimes to the wrong ssh instance:
Output
Started some_project #2 Started some_project #3 Started from command line by anonymous Building in workspace /var/lib/jenkins/workspace/some_project@2 [some_project@2] $ /bin/sh -xe /tmp/hudson1543608397242908784.sh Started some_project #4 Started from command line by anonymous Started from command line by anonymous Started from command line by anonymous Started some_project #4 Started from command line by anonymous Started from command line by anonymous Started from command line by anonymous Building in workspace /var/lib/jenkins/workspace/some_project@3 [some_project@3] $ /bin/sh -xe /tmp/hudson3327273428647305695.sh #!/bin/bash Started some_project #4 Started from command line by anonymous Started from command line by anonymous Started from command line by anonymous Building in workspace /var/lib/jenkins/workspace/some_project@3 [some_project@3] $ /bin/sh -xe /tmp/hudson3327273428647305695.sh Started from command line by anonymous Building in workspace /var/lib/jenkins/workspace/some_project [some_project] $ /bin/sh -xe /tmp/hudson5983434395853024371.sh + echo 'Hello SSH' Hello SSH + echo 'Sleep 2' Sleep 2 + sleep 10 + echo 'Hello SSH' Hello SSH + echo 'Sleep 3' Sleep 3 + sleep 10 Building in workspace /var/lib/jenkins/workspace/some_project@3 [some_project@3] $ /bin/sh -xe /tmp/hudson3327273428647305695.sh + echo 'Hello SSH' Hello SSH + echo 'Sleep 4' Sleep 4 + sleep 10 + echo 'Hello SSH' Hello SSH + echo 'Sleep 4' Sleep 4 + sleep 10 + echo 'Hello SSH' Hello SSH + echo 'Sleep 4' Sleep 4 + sleep 10 + echo 'Awake 3' Awake 3 + echo 'Awake 2' Awake 2 Finished: SUCCESS Completed some_project #2 : SUCCESS + echo 'Awake 4' Awake 4 Finished: SUCCESS Completed some_project #4 : SUCCESS Finished: SUCCESS Completed some_project #3 : SUCCESS + echo 'Awake 4' Awake 4 Finished: SUCCESS Completed some_project #4 : SUCCESS + echo 'Awake 4' Awake 4 Finished: SUCCESS Completed some_project #4 : SUCCESS
You will see that 3 out of 5 ssh sessions actually get the results of job #4.