-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
Description
New issue checklist
- I searched for existing GitHub issues
- I read pipeline troubleshooting guide
- I checked how to collect logs
Task name
AzurePowerShell
Task version
5
Issue Description
The AzurePowerShell@5
task fails on Linux agents when azurePowerShellVersion
is not specified, due to a bug in the script logic in Utility.ps1
.
When no version is provided in the YAML CI, the $targetAzurePs
parameter is set to the string "null"
, not $null
, which causes the fallback logic to be skipped and leads to an invalid path like /usr/share/az_null
.
This results in the following error, even when the Az module is preloaded:
Az version null not available locally on the agent. Downloading dynamically.
Validate-VersionParameters: Cannot convert value 'null' to type 'System.Version'.
Environment type (Please select at least one enviroment where you face this issue)
- Self-Hosted
- Microsoft Hosted
- VMSS Pool
- Container
Azure DevOps Server type
dev.azure.com (formerly visualstudio.com)
Azure DevOps Server Version (if applicable)
No response
Operation system
Ubuntu 22.04
Relevant log output
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command . '/agent/_work/_temp/9345e305-301d-4cac-8ceb-51e68b5473a1.ps1'
File saved!
VERBOSE: Module path not present as expected in hosted agent, skipping step to make module available.
##[debug]Processed: ##vso[telemetry.publish area=TaskHub;feature=AzurePowerShellV5]{"targetAzurePs":"null","moduleSource":"privateAgent"}
VERBOSE: The value of the module path is: /usr/share/az_null
VERBOSE: No module path found with this name
VERBOSE: The updated value of the PSModulePath is: /home/AzDevOps/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules
Exception: /agent/_work/_tasks/AzurePowerShell_72a1931b-effb-4d2e-8fd8-f8472a07cb62/5.257.0/Utility.ps1:94
Line |
94 | … throw ("Could not find the module path with given version …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Could not find the module path with given version.
##[debug]Exit code 1 received from tool '/usr/bin/pwsh'
##[debug]STDIO streams have closed for tool '/usr/bin/pwsh'
##[debug]task result: Failed
##[error]PowerShell exited with code '1'.
Full task logs with system.debug enabled
[REPLACE THIS WITH YOUR INFORMATION]