Skip to content

Commit c103afe

Browse files
gfraiteurclaude
andcommitted
Fix timestamp file creation for TeamCity Docker builds
Create timestamp file for all Docker image builds, not just -Claude mode. The file only affects Dockerfiles that COPY it (Dockerfile.claude). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent dad6cb2 commit c103afe

File tree

3 files changed

+37
-30
lines changed

3 files changed

+37
-30
lines changed

CLAUDE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,8 @@ Invoke-RestMethod -Uri "https://postsharp.teamcity.com/app/rest/buildQueue" -Met
127127
4. Bump version (see above)
128128
5. Monitor version bumping
129129
6. When completed, schedule deploy public
130+
131+
132+
## Warnings
133+
134+
NEVER COMMIT WITHOUT USER APPROVAL. Even if the user has given approval for a prior commit.

DockerBuild.ps1

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -458,23 +458,24 @@ Write-Host "Preparing context and mounts." -ForegroundColor Green
458458
# Create secrets JSON file.
459459
if (-not $KeepEnv)
460460
{
461+
# Create timestamp file for cache invalidation (only if building image)
462+
# This is used by Dockerfile.claude but doesn't affect other Dockerfiles
463+
if (-not $NoBuildImage)
464+
{
465+
if ($env:IS_TEAMCITY_AGENT)
466+
{
467+
$timestampFile = New-TeamCityTimestampFile -TimestampValue $Timestamp -DockerContextDir $dockerContextDirectory
468+
}
469+
else
470+
{
471+
$timestampFile = Get-TimestampFile -Update:$Update
472+
}
473+
}
474+
461475
if ($Claude)
462476
{
463477
# Use Claude-specific environment variables (filtered and renamed)
464478
New-ClaudeEnvJson
465-
466-
# Get/update timestamp file for cache invalidation (only if building image)
467-
if (-not $NoBuildImage)
468-
{
469-
if ($env:IS_TEAMCITY_AGENT)
470-
{
471-
$timestampFile = New-TeamCityTimestampFile -TimestampValue $Timestamp -DockerContextDir $dockerContextDirectory
472-
}
473-
else
474-
{
475-
$timestampFile = Get-TimestampFile -Update:$Update
476-
}
477-
}
478479
}
479480
else
480481
{
@@ -1039,9 +1040,9 @@ foreach (`$dir in `$gitDirectories) {
10391040
$initScriptContent | Set-Content -Path $initScript -Encoding UTF8
10401041
}
10411042

1042-
# Copy timestamp file to docker context (for Claude mode cache invalidation)
1043+
# Copy timestamp file to docker context (for cache invalidation)
10431044
# Skip if running on TeamCity - we already created the file directly in docker-context
1044-
if ($Claude -and $timestampFile -and -not $env:IS_TEAMCITY_AGENT)
1045+
if ($timestampFile -and -not $env:IS_TEAMCITY_AGENT)
10451046
{
10461047
$gDirectory = Join-Path $dockerContextDirectory ".g"
10471048
if (-not (Test-Path $gDirectory))

src/PostSharp.Engineering.BuildTools/Resources/DockerBuild.ps1

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -458,23 +458,24 @@ Write-Host "Preparing context and mounts." -ForegroundColor Green
458458
# Create secrets JSON file.
459459
if (-not $KeepEnv)
460460
{
461+
# Create timestamp file for cache invalidation (only if building image)
462+
# This is used by Dockerfile.claude but doesn't affect other Dockerfiles
463+
if (-not $NoBuildImage)
464+
{
465+
if ($env:IS_TEAMCITY_AGENT)
466+
{
467+
$timestampFile = New-TeamCityTimestampFile -TimestampValue $Timestamp -DockerContextDir $dockerContextDirectory
468+
}
469+
else
470+
{
471+
$timestampFile = Get-TimestampFile -Update:$Update
472+
}
473+
}
474+
461475
if ($Claude)
462476
{
463477
# Use Claude-specific environment variables (filtered and renamed)
464478
New-ClaudeEnvJson
465-
466-
# Get/update timestamp file for cache invalidation (only if building image)
467-
if (-not $NoBuildImage)
468-
{
469-
if ($env:IS_TEAMCITY_AGENT)
470-
{
471-
$timestampFile = New-TeamCityTimestampFile -TimestampValue $Timestamp -DockerContextDir $dockerContextDirectory
472-
}
473-
else
474-
{
475-
$timestampFile = Get-TimestampFile -Update:$Update
476-
}
477-
}
478479
}
479480
else
480481
{
@@ -1039,9 +1040,9 @@ foreach (`$dir in `$gitDirectories) {
10391040
$initScriptContent | Set-Content -Path $initScript -Encoding UTF8
10401041
}
10411042

1042-
# Copy timestamp file to docker context (for Claude mode cache invalidation)
1043+
# Copy timestamp file to docker context (for cache invalidation)
10431044
# Skip if running on TeamCity - we already created the file directly in docker-context
1044-
if ($Claude -and $timestampFile -and -not $env:IS_TEAMCITY_AGENT)
1045+
if ($timestampFile -and -not $env:IS_TEAMCITY_AGENT)
10451046
{
10461047
$gDirectory = Join-Path $dockerContextDirectory ".g"
10471048
if (-not (Test-Path $gDirectory))

0 commit comments

Comments
 (0)