Azure DevOps 和 Azure CLI:无法找到可执行文件

Azure DevOps & Azure CLI: Unable to locate executable file

在我基于 ubuntu 的 Azure DevOps 管道中尝试 运行 一个简单的 Azure CLI 任务时,我收到以下错误消息:

##[error]Script failed with error: Error: Unable to locate executable file: 
'/home/vsts/work/_temp/azureclitaskscript1637831708745.bat'. 
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.

如果我没看错,是没有找到内联脚本,对吧?我在这里错过了什么?这是完整的 YAML:

trigger:
- main
- dev

pool:
  vmImage: ubuntu-latest

steps:
- task: AzureCLI@2
  inputs:
    azureSubscription: 'My Subscription Name'
    scriptType: 'batch'
    scriptLocation: 'inlineScript'
    inlineScript: 'az --version'

你 运行 你在 Linux 上的任务,你不能在那里使用 batch,你需要选择 pscorebash,或者切换到 windows-latest vmImage。

Script Type*: Select the type of script to be executed on the agent. Task supports four types: Batch / Shell / PowerShell / PowerShell Core scripts, default selection being empty. Select Shell/PowerShell Core script when running on Linux agent or Batch/PowerShell/PowerShell Core script when running on Windows agent. PowerShell Core script can run on cross-platform agents (Linux, macOS, or Windows)

https://github.com/microsoft/azure-pipelines-tasks/tree/master/Tasks/AzureCLIV2#parameters-of-the-task

实际strings to pass to the arguments can be found in the task.json。任务似乎没有对这些字段进行任何验证,导致出现这种奇怪的错误情况。

            "options": {
                "ps": "PowerShell",
                "pscore": "PowerShell Core",
                "batch": "Batch",
                "bash": "Shell"
            }