我在git项目的根目录下有一个azure-pipelines.yml文件。
在这个文件中,我想在下一个任务中使用前一个任务的输出作为变量。
我的任务是:
在 PowerShell 中运行此 az 命令时,我会得到以下返回结果:
为什么变量名没有被primaryConnectionString的值所替换?
- task: AzureCLI@2
displayName: 'List info on read policy in DEV'
name: myOutput
inputs:
azureSubscription: mySub
scriptType: ps
scriptLocation: inlineScript
inlineScript: az servicebus topic authorization-rule keys list --resource-group myRG --namespace-name mySB --topic-name myTopic --name Listen
在 PowerShell 中运行此 az 命令时,我会得到以下返回结果:
{
"aliasPrimaryConnectionString": null,
"aliasSecondaryConnectionString": null,
"keyName": "Listen",
"primaryConnectionString": "Endpoint=sb://someKey",
"primaryKey": "somePrimaryKey",
"secondaryConnectionString": "Endpoint=sb://another key",
"secondaryKey": "someSecondaryKey"
}
我在流水线日志中得到了这个输出结果。 根据文档的说明,我期望可以在下一步骤中使用它。 例如:
- script: echo $(myOutput.primaryConnectionString)
与其获取 primaryConnectionString 的值,日志显示的是:
Starting: CmdLine
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.151.2
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
echo $(myOutput.primaryConnectionString)
========================== Starting Command Output ===========================
"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "d:\a\_temp\3d1130bd-f7f7-4e30-8ae2-31e6f9d0800e.cmd""
$(myOutput.primaryConnectionString)
Finishing: CmdLine
为什么变量名没有被primaryConnectionString的值所替换?