AzurePowerShell 任务找不到 filePath

Rac*_*hel 2 azure azure-powershell azure-devops azure-pipelines azure-yaml-pipelines

我尝试在 Azure Yaml Pipelines 中运行 PowerShell 脚本,但收到此错误:

##[error]The term 'D:\a\1\s\myPowershellFile.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Run Code Online (Sandbox Code Playgroud)

代码:

jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: $(myEnvironment)
    pool:
      vmImage: 'windows-latest'

    strategy:
      runOnce:
        deploy:
          steps:          
          - task: AzurePowerShell@5
            displayName: 'Run Powershell script'
            inputs:
              azureSubscription: $(azureConnectionName)
              scriptType: filePath
              scriptPath: './myPowershellFile.ps1'
              azurePowerShellVersion: latestVersion
Run Code Online (Sandbox Code Playgroud)

该文件被推送到触发构建的分支的存储库。$(Pipeline.Workspace)我还尝试使用and显式引用路径$(Build.SourcesDirectory)。版本 4 也不起作用。根据文档,这应该有效!

Rac*_*hel 5

经过更多研究后,我发现这篇文章说不会自动下载文件以进行部署作业。我添加了这一步,问题就解决了!

- checkout: self