Skip to content

Commit 02db576

Browse files
committed
DockerBuild.ps1: properly return exit code.
1 parent d007813 commit 02db576

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

DockerBuild.ps1

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ if (-not $env:IS_TEAMCITY_AGENT -and -not $NoClean)
112112
Write-Host "Cleaning up." -ForegroundColor Green
113113
if (Test-Path "artifacts")
114114
{
115-
Remove-Item artifacts -Force -Recurse -ProgressAction SilentlyContinue
115+
Remove-Item artifacts -Force -Recurse -ErrorAction SilentlyContinue
116116
}
117-
Get-ChildItem @("bin", "obj") -Recurse | Remove-Item -Force -Recurse -ProgressAction SilentlyContinue
117+
Get-ChildItem "bin" -Recurse | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
118+
Get-ChildItem "obj" -Recurse | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
118119
}
119120

121+
Write-Host "Preparing context and mounts." -ForegroundColor Green
120122
# Create secrets JSON file.
121123
if (-not $KeepEnv)
122124
{
@@ -299,9 +301,9 @@ if (-not $BuildImage)
299301
$dockerArgsAsString = $dockerArgs -join " "
300302

301303

302-
Write-Host "Executing: ``docker run --rm --memory=12g $VolumeMappingsAsString -w $SourceDirName $dockerArgsAsString $ImageName pwsh $pwshArgs -Command `"& .\Build.ps1 $buildArgsString`"``." -ForegroundColor Cyan
304+
Write-Host "Executing: ``docker run --rm --memory=12g $VolumeMappingsAsString -w $SourceDirName $dockerArgsAsString $ImageName pwsh $pwshArgs -Command `"& .\Build.ps1 $buildArgsString`; exit `$LASTEXITCODE`"``." -ForegroundColor Cyan
303305

304-
docker run --rm --memory=12g @VolumeMappings -w $SourceDirName @dockerArgs $ImageName pwsh $pwshArgs -Command "& .\Build.ps1 $buildArgsString"
306+
docker run --rm --memory=12g @VolumeMappings -w $SourceDirName @dockerArgs $ImageName pwsh $pwshArgs -Command "& .\Build.ps1 $buildArgsString`; exit `$LASTEXITCODE;"
305307
if ($LASTEXITCODE -ne 0)
306308
{
307309
Write-Host "Docker run (build) failed with exit code $LASTEXITCODE" -ForegroundColor Red

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ if (-not $BuildImage)
301301
$dockerArgsAsString = $dockerArgs -join " "
302302

303303

304-
Write-Host "Executing: ``docker run --rm --memory=12g $VolumeMappingsAsString -w $SourceDirName $dockerArgsAsString $ImageName pwsh $pwshArgs -Command `"& .\Build.ps1 $buildArgsString`"``." -ForegroundColor Cyan
304+
Write-Host "Executing: ``docker run --rm --memory=12g $VolumeMappingsAsString -w $SourceDirName $dockerArgsAsString $ImageName pwsh $pwshArgs -Command `"& .\Build.ps1 $buildArgsString`; exit `$LASTEXITCODE`"``." -ForegroundColor Cyan
305305

306-
docker run --rm --memory=12g @VolumeMappings -w $SourceDirName @dockerArgs $ImageName pwsh $pwshArgs -Command "& .\Build.ps1 $buildArgsString"
306+
docker run --rm --memory=12g @VolumeMappings -w $SourceDirName @dockerArgs $ImageName pwsh $pwshArgs -Command "& .\Build.ps1 $buildArgsString`; exit `$LASTEXITCODE;"
307307
if ($LASTEXITCODE -ne 0)
308308
{
309309
Write-Host "Docker run (build) failed with exit code $LASTEXITCODE" -ForegroundColor Red

0 commit comments

Comments
 (0)