Skip to content

Commit 6f210db

Browse files
gladjohnCopilot
andcommitted
ci(mi-e2e): resolve python.exe by full path so the step doesn't depend on the agent PATH
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5ad57850-7d1f-4b9a-bf9f-723d69a9687c
1 parent c1b2047 commit 6f210db

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

.Pipelines/template-pipeline-stages.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,16 @@ stages:
315315
workingDirectory: '$(System.DefaultWorkingDirectory)'
316316
script: |
317317
$ErrorActionPreference = 'Stop'
318-
python --version
318+
$py = (Get-Command python.exe -ErrorAction SilentlyContinue).Source
319+
if (-not $py) {
320+
$py = Get-ChildItem 'C:\Program Files\Python3*\python.exe','C:\Program Files (x86)\Python3*\python.exe','C:\Python3*\python.exe' -ErrorAction SilentlyContinue |
321+
Select-Object -First 1 -ExpandProperty FullName
322+
}
323+
if (-not $py) { throw 'Python not found on this agent. Install Python 3.x on the pool machine.' }
324+
Write-Host "Using Python: $py"
325+
& $py --version
319326
New-Item -ItemType Directory -Force -Path test-results | Out-Null
320-
python -m pytest -vv --junitxml=test-results/junit-mi-e2e-imds.xml tests/test_mi_e2e.py
327+
& $py -m pytest -vv --junitxml=test-results/junit-mi-e2e-imds.xml tests/test_mi_e2e.py
321328
env:
322329
PYTHONUNBUFFERED: '1'
323330
MSAL_TEST_MI_IMDS: '1'
@@ -367,9 +374,16 @@ stages:
367374
workingDirectory: '$(System.DefaultWorkingDirectory)'
368375
script: |
369376
$ErrorActionPreference = 'Stop'
370-
python --version
377+
$py = (Get-Command python.exe -ErrorAction SilentlyContinue).Source
378+
if (-not $py) {
379+
$py = Get-ChildItem 'C:\Program Files\Python3*\python.exe','C:\Program Files (x86)\Python3*\python.exe','C:\Python3*\python.exe' -ErrorAction SilentlyContinue |
380+
Select-Object -First 1 -ExpandProperty FullName
381+
}
382+
if (-not $py) { throw 'Python not found on this agent. Install Python 3.x on the pool machine.' }
383+
Write-Host "Using Python: $py"
384+
& $py --version
371385
New-Item -ItemType Directory -Force -Path test-results | Out-Null
372-
python -m pytest -vv --junitxml=test-results/junit-mi-e2e-arc.xml tests/test_mi_e2e.py
386+
& $py -m pytest -vv --junitxml=test-results/junit-mi-e2e-arc.xml tests/test_mi_e2e.py
373387
env:
374388
PYTHONUNBUFFERED: '1'
375389

0 commit comments

Comments
 (0)