AZure devops YAML管道Azure Powershell任务未执行

时间:2020-05-12 07:21:32

标签: build azure-devops yaml devops release

我在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

1 个答案:

答案 0 :(得分:0)

您的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'