Perforce as a VCS, p4 clean vs delete all files option in scheduled trigger

Completed

Hello, 

 

I'm setting up a TeamCity instance for a project that only uses Perforce for it's source control.  In getting up to speed, I've seen some options that lead TeamCity to the p4 clean command to clean up the workspace, but other places where TeamCity only offers an option to delete and resync the workspace.

I'm making use of the scheduled trigger to run a nightly build from a clean workspace. However I've hit a few snags, and wanting to switch the trigger to use "p4 clean" instead of deleting the directory and resyncing. The snags are:

1. Delete and resync of course incurs the overhead of needing to sync everything, I'd like to avoid that need as a build requires at least 30GB of source/assets to be synced first.

2. When delete and resync happens, disk space isn't freed up.  This has lead the build machine to run out of space overnight.  It's looking like TeamCity may be renaming the workspace folder to .old, and only deleting it 2 hours after the scheduled trigger ran.

3. Not all builds should be run clean, we try and keep the CI builds during the day running incrementally.

So with all that said, is there a way to ensure TeamCity only runs p4 clean during a scheduled trigger, and otherwise runs without a clean or delete when the VCS trigger occurs?

 

Thanks

-Tom

2 comments
Comment actions Permalink

Hello Tom!

teamcity.build.triggeredBy parameter will be equal to "Schedule Trigger" in case the build has been started on a schedule. You could use this to make a custom script step as a first step of the build which would, in case the build has been triggered via schedule, run p4 clean command or do nothing otherwise. Would this approach work for you?

0
Comment actions Permalink

Thanks for the tip Fedor, that should work for this setup, and even easier with the 2020.1 conditional build steps. Just got done upgrading the server, and will try using a condition based around teamcity.build.triggeredBy

0

Please sign in to leave a comment.