是否可以将批处理文件的语句输出设置为变量,例如:
findstr testing > %VARIABLE%
echo %VARIABLE%
Run Code Online (Sandbox Code Playgroud) 我的 git 项目根目录中有一个 azure-pipelines.yml 文件。在此文件中,我想在下一个任务中使用一个任务的输出作为变量。我的任务
- 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
Run Code Online (Sandbox Code Playgroud)
在 powershell 中运行此 az 命令时,我得到以下回报:
{
"aliasPrimaryConnectionString": null,
"aliasSecondaryConnectionString": null,
"keyName": "Listen",
"primaryConnectionString": "Endpoint=sb://someKey",
"primaryKey": "somePrimaryKey",
"secondaryConnectionString": "Endpoint=sb://another key",
"secondaryKey": "someSecondaryKey"
}
Run Code Online (Sandbox Code Playgroud)
我也在管道的日志中得到了这个输出。根据文档,我确实希望能够在下一步中使用它。例如:
- script: echo $(myOutput.primaryConnectionString)
Run Code Online (Sandbox Code Playgroud)
日志给我的不是获取 PrimaryConnectionString 的值,而是:
Starting: CmdLine
==============================================================================
Task : Command line
Description …Run Code Online (Sandbox Code Playgroud)