Skip to content

Enabling delete all files in the checkout directory before the build doesn't apply to distributed Build Graph runs #20

@redhook-willemtoorenburgh

Description

TeamCity Version: 2025.11 Build 207946 (Docker)
Unreal Engine Plugin Version: 1.3.4
Unreal Engine Version: 5.7.1 (GitHub sources)

YouTrack issue: https://youtrack.jetbrains.com/issue/TW-98269/Enabling-delete-all-files-in-the-checkout-directory-before-the-build-doesnt-apply-to-distributed-Build-Graph-runs

Steps to reproduce the problem:

  1. Prepare at least two build agents capable of running an Unreal Engine job
  2. Create a minimal reproduction build using the provided minimal Build Graph file
    • Create a new build in a project
    • Connect the build to source control, where the provided Build Graph file is committed (I used Perforce)
    • Add a new Unreal Engine build step in Build Graph mode, pointed to the Build Graph file
    • Set the Target to RunTest
    • Enable Distributed mode
  3. Run the build once. It should succeed.
  4. Run the build again. It should fail, with the file that gets created during the first one still existing.
  5. Run the build once more, enabling delete all files in the checkout directory before the build.

The actual result:
The build will fail due to the file created in previous runs still existing.

The expected result:
The build should succeed, as I expect enabling delete all files in the checkout directory before the build to clean the workspace of every executing agent.

It seems like enabling delete all files in the checkout directory before the build cleans the workspace of the agent which does the initial Build Graph JSON generation step.

Possible Workarounds

I could try to introduce an <Option> in the Build Graph that gets set by a TeamCity parameter, and run a manual cleaning step during the Build Graph run. This has a number of downsides:

  • When starting a new build, my users will always see the delete all files in the checkout directory before the build option first, and they may think it's enough for a clean build.
    • I thought about trying to listen to whether the user has enabled delete all files in the checkout directory before the build and set an <Option> based on that, but it doesn't seem like it's exposed as a parameter.
  • By the time the manual cleaning step runs, Unreal Automation Tool has already pulled in files from shared storage, making it possible for me to wipe things Build Graph wants to keep.

I also tried out Swabra, but couldn't make it work.

Build Graph script

<BuildGraph xmlns="http://www.epicgames.com/BuildGraph" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.epicgames.com/BuildGraph ../Schema.xsd" >

	<!--
		Notes:
			* Agent types can be whatever you like; this is just what I have set up locally
			* If you don't have PowerShell installed, feel free to substitute the <Spawn> steps with equivalent functionality
	-->

	<Agent Name="An Agent" Type="Linux">
		<Node Name="A Node">
			<!-- If the workspace is clean, this file shouldn't exist -->
			<Spawn Exe="pwsh" Arguments="-NonInteractive -NoProfile -Command &quot;If (Test-Path runtimefile.txt) { Write-Warning 'exists'; Exit 1 } Else { Write-Host 'notexist'; Exit 0 }&quot;" ErrorLevel="1" />

			<!-- Represents a file made during the build -->
			<WriteTextFile File="runtimefile.txt" Text="Yeet" />
		</Node>
	</Agent>

	<Agent Name="Another Agent" Type="Linux">
		<Node Name="Another Node">
			<!-- If the workspace is clean, this file shouldn't exist -->
			<Spawn Exe="pwsh" Arguments="-NonInteractive -NoProfile -Command &quot;If (Test-Path runtimefile.txt) { Write-Warning 'exists'; Exit 1 } Else { Write-Host 'notexist'; Exit 0 }&quot;" ErrorLevel="1" />

			<!-- Represents a file made during the build -->
			<WriteTextFile File="runtimefile.txt" Text="Yeet" />
		</Node>
	</Agent>

	<Agent Name="Yet Another Agent" Type="Win64">
		<Node Name="Yet Another Node">
			<!-- If the workspace is clean, this file shouldn't exist -->
			<Spawn Exe="pwsh" Arguments="-NonInteractive -NoProfile -Command &quot;If (Test-Path anotherruntimefile.txt) { Write-Warning 'exists'; Exit 1 } Else { Write-Host 'notexist'; Exit 0 }&quot;" ErrorLevel="1" />

			<!-- Represents a file made during the build -->
			<WriteTextFile File="anotherruntimefile.txt" Text="Yeet" />
		</Node>
	</Agent>

	<Aggregate Name="RunTest" Requires="A Node;Another Node;Yet Another Node" />

</BuildGraph>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions