If you are using Perforce server version 20141 or earlier P4jenkins uses a memory intensive version of 'p4 reconcile'. This older version skips permissions errors. For example:
P4 Task: tidying workspace to match have list. ... p4 reconcile -n -a -e -d -l -f /var/lib/jenkins/workspace/AutoCleanAnd___ + Not able to delete: /var/lib/jenkins/workspace/AutoCleanAndSync/submit/cfg/prod_Release.cfg duration: (68ms)
If you are using a later version of P4D a new streaming reconcile is used that is faster and uses less memory. In this implementation permissions errors fail the build. For example:
P4 Task: cleaning workspace to match have list .... p4 reconcile -f -w /var/lib/jenkins/workspace/AutoCleanAndSync/ ... +P4 Task: attempt: 1 ERROR: P4: Task Exception: com.perforce.p4java.exception.P4JavaException: com.perforce.p4java.exception.P4JavaException: hudson.AbortException: P4JAVA: Error(s): operating system will not allow deletion of file /var/lib/jenkins/workspace/AutoCleanAndSync/submit/cfg/prod_Release.cfg on client.Finished: FAILURE
Please add a flag that allows the old behavior to be used or the permissions error to be ignored.
Reproduction Steps:
(1) Create a freestyle job that syncs a file on Linux.
(2) Use the following shell script as a build step:
mkdir -p $WORKSPACE/submit/cfg
echo "test edit" > $WORKSPACE/submit/cfg/prod_Release.cfg
chmod ugo-w $WORKSPACE/submit/cfg
ls -la $WORKSPACE/submit
ls -la $WORKSPACE/submit/cfg
(3) Run the build.
(4) Run the build again. Error will be seen.
Note: P4 will successfully delete the file but would throw error messages if it needed to update any of the files in this directory. Therefore I have also raised a P4Java bug.
$ p4 reconcile -w -f ...
//depot/permissions/submit/cfg/prod_Release.cfg#none - deleted as /filestoreSSD/18.2/ws/permissions/submit/cfg/prod_Release.cfg
//depot/permissions/toplevel/tst#1 - refreshing /filestoreSSD/Vagrant/Swarm/18.2/ws/permissions/toplevel/tst
open for write: /18.2/ws/permissions/toplevel/tmp.19271.140538254619008.94: Permission denied