Files
local-ci-cd-system/scripts/New-BuildVM.ps1
T
Simone 10998247a0 fix(shims): add Linux fallback for venv Python path in all PS shims
All shims defaulted to F:\CI\python\venv\Scripts\python.exe when
CI_VENV_PYTHON was not set. On Linux host this caused instant failure.

Now uses $IsWindows (PS 6+ automatic var; absent on PS 5.1 = Windows)
to select /opt/ci/venv/bin/python on Linux. Windows paths unchanged.

Affects: Invoke-CIJob, Get-BuildArtifacts, Cleanup-OrphanedBuildVMs,
New-BuildVM, Remove-BuildVM, Wait-VMReady, Get-CIJobSummary,
Invoke-RemoteBuild, Watch-DiskSpace, Watch-RunnerHealth,
Set-CIGuestCredential, Test-CIGuestWinRM.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 22:43:48 +02:00

44 lines
1.1 KiB
PowerShell

#Requires -Version 5.1
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
# Shim: delegates to the Python ci_orchestrator CLI (`vm new`).
# Original PS implementation moved to git history; see plans/A3-closeout.md.
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[ValidateScript({ Test-Path $_ -PathType Leaf })]
[string] $TemplatePath,
[string] $SnapshotName = 'BaseClean',
[Parameter(Mandatory)]
[string] $CloneBaseDir,
[Parameter(Mandatory)]
[string] $JobId,
[string] $VmrunPath = 'C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe'
)
$pyArgs = @(
'--template-path', $TemplatePath,
'--snapshot-name', $SnapshotName,
'--clone-base-dir', $CloneBaseDir,
'--job-id', $JobId,
'--vmrun-path', $VmrunPath
)
$venvPython = $env:CI_VENV_PYTHON
if (-not $venvPython) {
# $IsWindows exists only on PS 6+; absent on PS 5.1 (always Windows)
if ($null -ne $IsWindows -and $IsWindows -eq $false) {
$venvPython = '/opt/ci/venv/bin/python'
} else {
$venvPython = 'F:\CI\python\venv\Scripts\python.exe'
}
}
& $venvPython -m ci_orchestrator vm new @pyArgs
exit $LASTEXITCODE