gpt4 book ai didi

powershell 中的 Azure DevOps 变量组

转载 作者:行者123 更新时间:2023-12-02 23:36:31 25 4
gpt4 key购买 nike

我在 Azure Devops 变量组中定义了一个变量,如下所示:

apple-prod-branch  refs/heads/release-823T0709

上面的变量在 azure pipeline powershell 命令中调用时有效,如下调用:

"Write-Host $(apple-prod-branch)" 

Output is:
refs/heads/release-823T0709

在上面的变量名 apple-prod-branch 中,apple 是存储库名称。如何使用存储库名称并使用这样的变量?

$repo_name = "apple"

"Write-Host $($(repo-name)-prod-branch)"

最终结果需要是

refs/heads/release-823T0709

最佳答案

How can I use the repo name and use a variable like this ?

您可以使用以下 PowerShell 脚本:

$test = "$(repo-name)-prod-branch"

$branch= [Environment]::GetEnvironmentVariable($test)

echo $branch

结果:

enter image description here

关于powershell 中的 Azure DevOps 变量组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70976661/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com