我的经典管道上的 Azure CLI 任务使用内联脚本显示错误
The Azure CLI task on my classic pipeline shows an error using inlinescript
我在我的 Azure 经典 管道(无 YAML)上使用 Azure CLI task。管道正常工作,唯一的问题是此任务显示错误。我使用这个内联脚本来完成任务:
$containers = $(call az storage container list --connection-string '...') | ConvertFrom-Json -Depth 5
$containers | where{$_.name -like "..."}
$lastContainers = $containers | Select-Object -Last 5
$containers.ForEach({ If ($_ -notin $lastContainers) {call az storage container delete --name $_.name --connection-string '...' } });
我用 ...
替换了我的真实连接字符串。当我 运行 管道(所有前面的步骤都成功结束)时,我收到关于最后一个任务 (Azure CLI) 的错误:
D:\a\s>$containers = $(call az storage container list --connection-string '...') | ConvertFrom-Json -Depth 5
'$containers' is not recognized as an internal or external command, operable program or batch file.
##[error]Script failed with error: Error: The process 'D:\a\_temp\azureclitaskscript1587632019088.bat' failed with exit code 255
我有一个类似的 YAML 管道,它使用相同的脚本,一切正常。我在 Azure 命令前面使用 call
as suggested on GitHub。
在 AzureCLI@2
你 select 脚本中输入:
Type of script: PowerShell/PowerShell Core/Bat/Shell script. Select
bash/pscore script when running on Linux agent or batch/ps/pscore
script when running on Windows agent. PowerShell Core script can run
on cross-platform agents (Linux, macOS, or Windows)
此外,Linux 和 Windows 可能会出现一些差异(此问题与 call
语句有关),但如果您 select 有 pscore
例如,您应该去掉“call”语句。
所以请提供更多信息在什么系统和终端你运行这个脚本给你更多的帮助。
我 运行 你在 powershell 中没有 call
脚本,一切都很好。请尝试运行那样。
我在我的 Azure 经典 管道(无 YAML)上使用 Azure CLI task。管道正常工作,唯一的问题是此任务显示错误。我使用这个内联脚本来完成任务:
$containers = $(call az storage container list --connection-string '...') | ConvertFrom-Json -Depth 5
$containers | where{$_.name -like "..."}
$lastContainers = $containers | Select-Object -Last 5
$containers.ForEach({ If ($_ -notin $lastContainers) {call az storage container delete --name $_.name --connection-string '...' } });
我用 ...
替换了我的真实连接字符串。当我 运行 管道(所有前面的步骤都成功结束)时,我收到关于最后一个任务 (Azure CLI) 的错误:
D:\a\s>$containers = $(call az storage container list --connection-string '...') | ConvertFrom-Json -Depth 5
'$containers' is not recognized as an internal or external command, operable program or batch file.
##[error]Script failed with error: Error: The process 'D:\a\_temp\azureclitaskscript1587632019088.bat' failed with exit code 255
我有一个类似的 YAML 管道,它使用相同的脚本,一切正常。我在 Azure 命令前面使用 call
as suggested on GitHub。
在 AzureCLI@2
你 select 脚本中输入:
Type of script: PowerShell/PowerShell Core/Bat/Shell script. Select bash/pscore script when running on Linux agent or batch/ps/pscore script when running on Windows agent. PowerShell Core script can run on cross-platform agents (Linux, macOS, or Windows)
此外,Linux 和 Windows 可能会出现一些差异(此问题与 call
语句有关),但如果您 select 有 pscore
例如,您应该去掉“call”语句。
所以请提供更多信息在什么系统和终端你运行这个脚本给你更多的帮助。
我 运行 你在 powershell 中没有 call
脚本,一切都很好。请尝试运行那样。