我在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发布于 2020-05-13 10:43:26
你的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'https://stackoverflow.com/questions/61745963
复制相似问题