小编kir*_*jan的帖子

将 Powershell 脚本中的值返回到 Azure DevOps 任务

我有一个返回字符串值的 Powershell 脚本。我使用 AzurePowerShell 任务调用此脚本,并且希望保留返回的值以便在同一管道内的后续任务中使用它。我怎样才能做到这一点?有什么想法吗?

脚本Powershelltest.ps1

function a {
   <<processing steps>>
   return $(testString)
}
Run Code Online (Sandbox Code Playgroud)

管道:

- task: AzurePowerShell@ 
  ScriptPath: Powershelltest.ps1 (calls the above powershell script)

- task: AzureCLI@
  inlineScript: | 
    use the value from $testString(??)
Run Code Online (Sandbox Code Playgroud)

如何在第一个任务 (AzurePowerShell) 中捕获 Powershell 的返回值并在 AzureCLI 任务中使用它?

谢谢

powershell azure azure-devops

5
推荐指数
1
解决办法
2599
查看次数

标签 统计

azure ×1

azure-devops ×1

powershell ×1