azure-devops - 如何将 PowerShell 命令的输出存储在 Azure DevOps 管道输出变量中并在下一阶段使用?
问题描述
我试图从 Azure DevOps Pipeline Azure PowerShell 任务执行以下代码,并在管道“输出变量”中检索输出,并将输出变量用作下一阶段的输入。这个怎么做?下面的输出数组还是对象?
PS C:\> Get-AzDataFactoryV2IntegrationRuntimeKey -ResourceGroupName 'rg-test-dfv2' -DataFactoryName 'test-df-eu2' -Name 'test-selfhost-ir'
AuthKey1 AuthKey2
-------- --------
IR@89895504-f647-48fd-8dd3-42fa556d67e3****** IR@89895504-f647-48fd-8dd3-42fa556d67e3****
解决方案
此命令的输出是一个对象PSIntegrationRuntimeKeys
,要将输出变量用作下一阶段的输入,您可以点击此链接 -在 Azure DevOps Release Pipelines 中将变量从一个阶段传递到另一个阶段。
更新:
您可以使用下面的命令,将$authkey1
和存储$authkey2
在单独的变量中。
$keys = Get-AzDataFactoryV2IntegrationRuntimeKey -ResourceGroupName <group-name> -DataFactoryName joyfactory -Name integrationRuntime2
$authkey1 = $keys.AuthKey1
$authkey2 = $keys.AuthKey2