I have a number of jobs that are named differently, and do similar but different operations, but have the same perforce mapping and run the same setup.
I wanted to share a workspace amongst all those jobs, so that i can benefit from the p4sync and setup caching.
I wrote my jobs like this:
When 2 instances of the job run on the same node, jenkins correctly allocates second workspace at C:\MyCustomWorkspace@2, syncs it etc.
After the concurrent runs have finished and I run the job again, there is a high chance that the job will fail during the p4sync step with an error message that's indicating that the p4 root is set incorrectly:
> Path 'C:\MyCustomWorkspace/...' is not under client's root 'C:\MyCustomWorkspace%402'.
More complete console log of the p4 operations:
1. Create a pipeline job using the code I pasted above and pin it on a single node.
2. Change the //Do stuff to something like a 1 min sleep
3. Start 2 runs of the job, which should run on the same node, and verify that jenkins had created 2 different workspaces. You might want to wait until the p4 sync of the first run has finished before starting the second one.
4. After the 2 runs have finished, start a 3rd run
5. The 3rd run will probably fail.
Note: I tried creating my custom workspace inside my jenkins workspace root, and experienced the same issue.