简体   繁体   English

错误:无法找到可执行文件:在 ADO 管道中运行 Azure CLI 任务时出现“powershell”

[英]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.

相关问题 Azure DevOps 托管代理管道“无法找到可执行文件:'Powershell' - Azure DevOps hosted agent pipeline "Unable to locate executable file: 'Powershell' Azure Pipeline 错误无法找到可执行文件:&#39;databricks - Azure Pipeline error Unable to locate executable file: 'databricks Azure devops 管道 ArchiveFiles 错误:无法找到可执行文件:'zip' - Azure devops pipeline ArchiveFiles error: Unable to locate executable file: 'zip' Azure DevOps &amp; Azure CLI:无法定位可执行文件 - Azure DevOps & Azure CLI: Unable to locate executable file Azure DevOps 管道无法找到可执行文件:“terraform” - Azure DevOps Pipeline unable to locate executable file: 'terraform' 无法找到可执行文件:Azure Devops 管道上的简单脚本出现“bash”错误 - Unable to locate executable file: 'bash' error for a simple script on Azure Devops Pipeline 无法找到可执行文件:“bash”错误:使用 Bash@3 Azure DevOps 任务的内联脚本 - Unable to locate executable file: 'bash" error : Inline script using Bash@3 Azure DevOps task 如何解决无法定位可执行文件:'pwsh'。 请验证在使用 Azure rest API 获取 buildid 时文件路径是否存在错误? - How to resolve Unable to locate executable file: 'pwsh'. Please verify either the file path exists error when getting buildid with Azure rest API? 从 DevOps Pipeline 中的 Azure PowerShell 任务登录到 Azure CLI - Login to Azure CLI from Azure PowerShell task in DevOps Pipeline Azure 管道 + Maven:无法找到可执行文件:'mvn' - Azure Pipelines + Maven: Unable to locate executable file: 'mvn'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM