kir*_*jan 5 powershell azure 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 任务中使用它?
谢谢
使用此命令:##vso[task.setvariable variable=testString]$testString'
在您的第一个任务中。在第二个任务中,您将像这样调用变量:$(testString)。
您的函数应如下所示:
function a {
<<processing steps>>
##vso[task.setvariable variable=testString]$testString'
}
Run Code Online (Sandbox Code Playgroud)
如果只想在后续步骤中使用该值,则不一定需要返回该值。
归档时间: |
|
查看次数: |
2599 次 |
最近记录: |