【问题标题】:AZure devops YAML pipeline Azure powershell task not executingAZure devops YAML 管道 Azure powershell 任务未执行
【发布时间】:2020-08-27 22:53:39
【问题描述】:

我在 Azure DevOps YAML 管道中编写了一个 Azure PowerShell 任务,如下所示

  - task: AzurePowerShell@3
    displayName: 'Invoke Test'
    inputs:
     azureSubscription: 'subscriptionname'
     ScriptPath: '$(Build.SourcesDirectory)\ProjectName\Scripts\Build\TestRelease.ps1'
     ScriptArguments: -testfilepath '$(Build.SourcesDirectory)\ProjectName\Releases\test.json -JsonFilepath '$(Build.SourcesDirectory)\test\qa\test_qa.json' -AzuredevopsService $(AzuredevopsService) -Verbose
     azurePowerShellVersion: LatestVersion

即使管道作业成功执行,上述 PowerShell 任务也没有执行并获取如下所示的日志。当我从经典编辑器管道调用时,相同的 PowerShell 脚本正在运行

  ## Initializing Azure Complete
  ## Beginning Script Execution
  & 'C:\devops\vsts-agent-win-x64-2.154.3\_work\10\s\ProjectName\Scripts\Build\TestRelease.ps1' -testfilepath 'C:\devops\vsts-agent-win-x64-2.154.3\_work\10\s\ProjectName\Releases\test.json' -JsonFilepath 'C:\devops\vsts-agent-win-x64-2.154.3\_work\10\s\test\qa\test_qa.json' -AzuredevopsService https://test.azure.com -organisation OrgName -Verbose
 ## Script Execution Complete

【问题讨论】:

    标签: build azure-devops yaml devops release


    【解决方案1】:

    您的 YAML 似乎有问题。请去掉ScriptArguments中路径的单引号(')。

    所以,任务设置应该如下:

    - task: AzurePowerShell@3
      displayName: 'Invoke Test'
      inputs:
        azureSubscription: 'subscriptionname'
        ScriptPath: '$(Build.SourcesDirectory)\ProjectName\Scripts\Build\TestRelease.ps1'
        ScriptArguments: '-testfilepath $(Build.SourcesDirectory)\ProjectName\Releases\test.json -JsonFilepath $(Build.SourcesDirectory)\test\qa\test_qa.json -AzuredevopsService $(AzuredevopsService) -Verbose'
        azurePowerShellVersion: 'LatestVersion'
    

    如果这仍然不起作用,请尝试该任务的其他版本。 例如:

    - task: AzurePowerShell@5
      displayName: 'Invoke Test'
      inputs:
        azureSubscription: 'subscriptionname'
        ScriptType: 'FilePath'
        ScriptPath: '$(Build.SourcesDirectory)\ProjectName\Scripts\Build\TestRelease.ps1'
        ScriptArguments: '-testfilepath $(Build.SourcesDirectory)\ProjectName\Releases\test.json -JsonFilepath $(Build.SourcesDirectory)\test\qa\test_qa.json -AzuredevopsService $(AzuredevopsService) -Verbose'
        azurePowerShellVersion: 'LatestVersion'
    

    【讨论】:

    • @tjdoubts 您是否通过删除ScriptArguments 中路径的单引号(')来解决问题,如答案中所述?这里有更新吗?
    • 不,安迪,这个问题没有解决。现在同样的问题也出现在经典管道中。
    猜你喜欢
    • 2020-08-07
    • 1970-01-01
    • 2021-01-20
    • 2020-05-28
    • 2020-05-23
    • 2021-11-23
    • 2020-10-05
    • 1970-01-01
    • 2020-04-02
    相关资源
    最近更新 更多