Skip to content

Commit d44c90a

Browse files
gfraiteurclaude
andcommitted
Skip registry push when -NoBuildImage is used and print Claude exit code
Prevent unauthenticated push attempts when the registry flow is skipped. Also print Claude's exit code to the console in RunClaude.ps1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8cf51ff commit d44c90a

3 files changed

Lines changed: 40 additions & 12 deletions

File tree

DockerBuild.ps1

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,23 @@ try
371371

372372
# Git identity - CLAUDE_ prefixed vars take precedence, then GIT_USER_*, then git config
373373
$gitUserName = $env:CLAUDE_GIT_USER_NAME
374-
if (-not $gitUserName) { $gitUserName = $env:GIT_USER_NAME }
375-
if (-not $gitUserName) { $gitUserName = git config --global user.name }
374+
if (-not $gitUserName)
375+
{
376+
$gitUserName = $env:GIT_USER_NAME
377+
}
378+
if (-not $gitUserName)
379+
{
380+
$gitUserName = git config --global user.name
381+
}
376382
$gitUserEmail = $env:CLAUDE_GIT_USER_EMAIL
377-
if (-not $gitUserEmail) { $gitUserEmail = $env:GIT_USER_EMAIL }
378-
if (-not $gitUserEmail) { $gitUserEmail = git config --global user.email }
383+
if (-not $gitUserEmail)
384+
{
385+
$gitUserEmail = $env:GIT_USER_EMAIL
386+
}
387+
if (-not $gitUserEmail)
388+
{
389+
$gitUserEmail = git config --global user.email
390+
}
379391
if ($gitUserName)
380392
{
381393
$claudeEnv["GIT_USER_NAME"] = $gitUserName
@@ -1413,7 +1425,8 @@ $envVarAssignments$gitConfigCommands$postInitCommands
14131425
# Registry authentication and pull logic
14141426
$builtNewImage = $false
14151427
$dockerConfigArg = @()
1416-
$imageExistsInRegistry = $false
1428+
# When we skip the registry flow (e.g. -NoBuildImage parameter), assume image is already in registry to avoid unauthenticated push
1429+
$imageExistsInRegistry = ($NoBuildImage -or $existingContainerId)
14171430

14181431
if ($dockerRegistry -and -not $NoBuildImage -and -not $existingContainerId)
14191432
{
@@ -1823,7 +1836,7 @@ RUN if [ -n "`$MOUNTPOINTS" ]; then \
18231836
if ($script:RegistryPushJob)
18241837
{
18251838
Write-Host ""
1826-
Write-Host "Checking registry push status..." -ForegroundColor Cyan
1839+
Write-Host "Waiting for registry push..." -ForegroundColor Cyan
18271840

18281841
# Wait for the job to complete with a timeout
18291842
$pushJob = $script:RegistryPushJob

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,23 @@ try
371371

372372
# Git identity - CLAUDE_ prefixed vars take precedence, then GIT_USER_*, then git config
373373
$gitUserName = $env:CLAUDE_GIT_USER_NAME
374-
if (-not $gitUserName) { $gitUserName = $env:GIT_USER_NAME }
375-
if (-not $gitUserName) { $gitUserName = git config --global user.name }
374+
if (-not $gitUserName)
375+
{
376+
$gitUserName = $env:GIT_USER_NAME
377+
}
378+
if (-not $gitUserName)
379+
{
380+
$gitUserName = git config --global user.name
381+
}
376382
$gitUserEmail = $env:CLAUDE_GIT_USER_EMAIL
377-
if (-not $gitUserEmail) { $gitUserEmail = $env:GIT_USER_EMAIL }
378-
if (-not $gitUserEmail) { $gitUserEmail = git config --global user.email }
383+
if (-not $gitUserEmail)
384+
{
385+
$gitUserEmail = $env:GIT_USER_EMAIL
386+
}
387+
if (-not $gitUserEmail)
388+
{
389+
$gitUserEmail = git config --global user.email
390+
}
379391
if ($gitUserName)
380392
{
381393
$claudeEnv["GIT_USER_NAME"] = $gitUserName
@@ -1413,7 +1425,8 @@ $envVarAssignments$gitConfigCommands$postInitCommands
14131425
# Registry authentication and pull logic
14141426
$builtNewImage = $false
14151427
$dockerConfigArg = @()
1416-
$imageExistsInRegistry = $false
1428+
# When we skip the registry flow (e.g. -NoBuildImage parameter), assume image is already in registry to avoid unauthenticated push
1429+
$imageExistsInRegistry = ($NoBuildImage -or $existingContainerId)
14171430

14181431
if ($dockerRegistry -and -not $NoBuildImage -and -not $existingContainerId)
14191432
{
@@ -1823,7 +1836,7 @@ RUN if [ -n "`$MOUNTPOINTS" ]; then \
18231836
if ($script:RegistryPushJob)
18241837
{
18251838
Write-Host ""
1826-
Write-Host "Checking registry push status..." -ForegroundColor Cyan
1839+
Write-Host "Waiting for registry push..." -ForegroundColor Cyan
18271840

18281841
# Wait for the job to complete with a timeout
18291842
$pushJob = $script:RegistryPushJob

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ if ($Prompt)
231231

232232
# Clean up prompt file
233233
Remove-Item $promptFile -ErrorAction SilentlyContinue
234+
235+
Write-Host "Claude exited with code $exitCode" -ForegroundColor $(if ($exitCode -eq 0) { "Green" } else { "Red" })
234236
exit $exitCode
235237
}
236238
else

0 commit comments

Comments
 (0)