[英]Error: Unable to locate executable file: 'powershell' when running Azure CLI task in ADO pipeline
I am trying to run an Azure CLI task in pipeline and getting the following error :我正在尝试在管道中运行 Azure CLI 任务并收到以下错误:
Starting: AzureCLI
==============================================================================
Task : Azure CLI
Description : Run Azure CLI commands against an Azure subscription in a PowerShell
Core/Shell script when running on Linux agent or PowerShell/PowerShell Core/Batch script when running on Windows agent.
Version : 2.1.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-cli
==============================================================================
##[error]Script failed with error: Error: Unable to locate executable file: 'powershell'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
Finishing: AzureCLI
The pre-requisites mentioned in https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-cli?view=azure-devops is fulfilled.满足https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-cli?view=azure-devops 中提到的先决条件。
**Pre-requisites mentioned in the ms site :**
Microsoft hosted agents have Azure CLI pre-installed. However if you are using private agents, install Azure CLI on the computer(s) that run the build and release agent. If an agent is already running on the machine on which the Azure CLI is installed, restart the agent to ensure all the relevant stage variables are updated.
I am not using any private agents.我没有使用任何私人代理。 I am using a free subscription.
我正在使用免费订阅。
The task in pipeline yaml is as :管道 yaml 中的任务如下:
- task: AzureCLI@2
inputs:
azureSubscription: 'Free Trial(<My Subscription id>)'
scriptType: 'ps'
scriptLocation: 'inlineScript'
inlineScript: |
az --version
az account show
Why is the agent not able to find powershell in its system!!为什么代理在它的系统中找不到powershell!! Is this a bug?
这是一个错误吗?
Thanks!谢谢!
Hi try without "scriptType" and change the CLI version to 1, Please see the below script,嗨,尝试不使用“scriptType”并将 CLI 版本更改为 1,请参阅以下脚本,
- task: AzureCLI@1
inputs:
azureSubscription: 'Free Trial(<My Subscription id>)'
scriptLocation: 'inlineScript'
inlineScript: |
az --version
az account show
I think you might be using a Linux agent such as 'ubuntu-latest'.我认为您可能正在使用诸如“ubuntu-latest”之类的 Linux 代理。 Try changing it back to AzureCLI@2 and set
scriptType: pscore
.尝试将其改回 AzureCLI@2 并设置
scriptType: pscore
。 scriptType: ps
doesn't work on Linux. scriptType: ps
在 Linux 上不起作用。
- task: AzureCLI@2
displayName: Azure CLI
inputs:
azureSubscription: 'sc-name'
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
az account show
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.