build - AZure devops YAML 管道 Azure powershell 任务未执行
问题描述
我在 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
解决方案
您的 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'
推荐阅读
- php - 我var_dump了一个对象类型的数据,但是#number是什么意思呢?为什么我重新加载页面时总是增加
- bash - Substarct bash 变量作为名称
- pandas - Pandas:将一列字符串转换为日期并再次返回的更好/更快的方法?
- sql - 使用 Oracle SQL Developer 的 SQL Like 和通配符
- go - 导入从 Go 构建的 Dll 和运行时错误
- c++ - 为什么在运行我的代码后显示 bad_alloc 消息
- mongoose - 在使用猫鼬删除此文档之前,如何删除文档中引用的文件?
- javascript - 为移动设备上的弹性项目添加滑动功能
- r - 使用 R pwr 包绘制功率与效果大小的关系
- node.js - axios 请求错误:使用 Heroku 的 ECONNREFUSED