@@ -122,17 +122,11 @@ function before_script_steps($with_docker_auth = false) {
122122 GIT_STRATEGY: none
123123 IMAGE: "registry.ddbuild.io/images/mirror/datadog/dd-trace-ci:php-${PHP_MAJOR_MINOR}_windows"
124124 script: |
125- # Force-remove all running Docker containers before touching the workspace.
126- # A container from a previous job run may still be alive with the workspace volume mounted,
127- # holding an open handle on php_ddtrace.dll — which makes rd /s /q fail with "Access is denied".
125+ # Kill leftover containers — a previous run may still hold php_ddtrace.dll open.
128126 $containers = docker ps -aq 2>$null
129127 if ($containers) { docker rm -f $containers 2>$null }
130128
131- # Reliable workspace cleanup: navigate to parent and use cmd.exe "rd /s /q" on the whole
132- # workspace directory. cmd.exe rd correctly handles Windows junction points (removes the
133- # junction entry without following it into its target), unlike PowerShell's Remove-Item
134- # -Recurse which throws reparse point mismatch errors on PS 5.1 when the workspace
135- # contains junctions (e.g. created by switch-php) or NTFS symlinks (from core.symlinks clone).
129+ # Use cmd.exe rd from the parent dir: handles junctions/symlinks that PS5.1 Remove-Item can't.
136130 Write-Host "Performing workspace cleanup..."
137131 $workspace = $PWD.Path
138132 Push-Location ..
@@ -145,10 +139,8 @@ function before_script_steps($with_docker_auth = false) {
145139 if ($remaining) { Write-Host "WARNING: could not remove: $($remaining.Name -join ', ')" }
146140 Write-Host "Cleanup complete."
147141
148- # Fail fast on PowerShell cmdlet errors (works on PS 5.1+) .
142+ # PS 5.1 ignores $PSNativeCommandUseErrorActionPreference — use $LASTEXITCODE checks instead .
149143 $ErrorActionPreference = 'Stop'
150- # Note: $PSNativeCommandUseErrorActionPreference requires PS 7.3+ and is silently ignored on PS 5.1
151- # (Windows Server 2019 default). Use explicit $LASTEXITCODE checks for native commands instead.
152144
153145 # Manual git clone with proper config
154146 Write-Host "Cloning repository..."
0 commit comments