我有一個 Powershell 腳本,它回傳一個字串值。我正在使用 AzurePowerShell 任務呼叫此腳本,并且我希望保留回傳值以在同一管道內的后續任務中使用它。我怎樣才能做到這一點?有什么想法嗎?
function a {
<<processing steps>>
return $(testString)
}
- task: AzurePowerShell@
ScriptPath: Powershelltest.ps1 (calls the above powershell script)
- task: AzureCLI@
inlineScript: |
use the value from $testString(??)
How can I catch the return value from Powershell in the first task (AzurePowerShell) and use it in AzureCLI task?
Thanks
[1]: https://i.stack.imgur.com/Ktlaf.png
uj5u.com熱心網友回復:
使用此命令:##vso[task.setvariable variable=testString]$testString'在您的第一個任務中。在您的第二個任務中,您將像這樣呼叫變數:$(testString)。
您的函式應如下所示:
function a {
<<processing steps>>
##vso[task.setvariable variable=testString]$testString'
}
如果只想在后續步驟中使用它,則不一定需要回傳該值。
鏈接:https : //docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml,batch#expansion-of-variables
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/323341.html
標籤:天蓝色 电源外壳 azure-devops
下一篇:PowerShell多執行緒
