Hi ramganesht.
Thanks. I've easily reproduced this and modified this to an enhancement request.
As you mention at the moment there is no ability to resolve files on publish. It just assumes that is only one build running at a time and this job is the only thing publishing to it or it doesnt matter if you overwrite For a build artifact such as an executable binary or a ray traced video that is valid. It doesnt matter if the binary created in the second job overwrites the first because you cant merge the content.
For text artifacts where the build is adding something to them P4Publish would need to have a resolve -am then resolve -at action.
The two workarounds I can think of are:
(1) Use P4Groovy to do the resolve and publish. This may or may not work and you may hit unexpected behavior as mentioned in JENKINS-59888 so you will probably need a lot of defensive coding to pickup errors and act on them. More on P4Groovy cab be found in:
https://www.perforce.com/manuals/jenkins/Content/P4Jenkins/p4groovy.html?Highlight=P4Groovy
(2) Similar to above use a script/program outside P4Jenkins to do the publish. For example using the same workspace perform p4 edit, p4 sync, p4 resolve and p4 submit operations in a batch file or shell script
Reproduction steps:
(1) Add a file called 'test.txt' to your depot path.
(2) Create a freestyle job that syncs files to a linux build host.
(3) In the Freestyle job have a build step that runs the following shell code:
chmod +w test.txt
date >> test.txt
sleep 120
(4) Include a publish step to publish the contents of the workspace.
(5) Run the build job.
(6) During the 120 second pause, submit two new versions of test.txt outside of Jenkins that contain recognizable edits.
(7) When the build job completes look at the latest contents of test.txt. It will not contain the new edits you made in step (6).
Hi ramganesht - Are you saying that P4Publish overwrites anything submitted in the past 7 minutes by other jobs or that is is reveryting some of the work that was done in this job?