Thanks antemotion. I was easily able to reproduce that behavior.
Is there a reason you need it to build every night even if there were no changes?
The "Build periodically" is using 'now' in the sync command which is where P4_CHANGELIST is picked up from:
P4 Task: syncing files at client/label: now
... p4 sync -q /var/lib/jenkins/workspace/Polling Latest Change/...@now
When using polling an explicit changelist is chosen:
P4 Task: syncing files at change: 2788
... p4 sync -q /var/lib/jenkins/workspace/Polling Latest Change/...@2788
The workaround would be to use the 'Poll SCM' build trigger but will only build if the code has changed since the last time it polled.
Reproduction Steps:
(1) Create a freestyle job
(2) Set 'Source Code Management' to 'Perforce Software'.
(3) Use a manual workspace that syncs whole test depot. For example:
(4) Set 'Polling build filters' to 'Polling Latest Change'.
(5) Set the 'Build Triggers' to 'Build periodically' with a schedule of every minute:
(6) Add a build step that displays 'P4_CHANGELIST'. For example on a Linux master or slave use 'Execute Shell' :
echo P4_CHANGELIST is:
echo $P4_CHANGELIST
(7) Save the job.
(8) Wait 1 minute.
(9) Check the console log for the job just exeuted. You will see 'P4_CHANGELIST' is set to 'now'.
Workaround:
Use the build trigger 'Poll SCM' instead of 'Build periodically'.
Hi antemotion,
How are you starting the job? I have P4-Plugin 1.13.3 installed and if I trigger the job through polling or the 'Poll Now' button I see the correct changelist:
If I click the 'Build Now' button I see 'now' because polling did not run: