简体   繁体   English

Azure devops 变量组在 powershell

[英]Azure devops variable groups in powershell

I have a variable defined in Azure devops variable group like below:我在 Azure devops 变量组中定义了一个变量,如下所示:

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

The above variable works when called in azure pipeline powershell command when called like:上述变量在 azure 管道 powershell 命令中调用时起作用,如下所示:

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

Output is: 
refs/heads/release-823T0709

In the above variable name apple-prod-branch, apple is the repo name.在上面的变量名 apple-prod-branch 中,apple 是 repo 名称。 How can I use the repo name and use a variable like this?如何使用 repo 名称并使用这样的变量?

$repo_name = "apple"

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

End result needs to be最终结果必须是

refs/heads/release-823T0709

How can I use the repo name and use a variable like this?如何使用 repo 名称并使用这样的变量?

You can use the following PowerShell Script:您可以使用以下 PowerShell 脚本:

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

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

echo $branch

Result:结果:

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何导出多个 Azure DevOps 变量组? - How to export multiple Azure DevOps Variable Groups? 将 Azure Powershell 变量分配给 DevOps 管道变量 - Assign Azure Powershell variable to DevOps Pipeline variable 如何限制项目参与者删除 Azure Devops 中的变量组/变量 - How to restrict Project Contributers to delete Variable Groups/Variables in Azure Devops 未从 Azure Devops 管道中的变量组中的变量获取任何值 - Not getting any values from variables in variable groups in Azure Devops pipeline 如何将 Azure DevOps 的变量替换为 PowerShell 的变量? - How can instead of the variable of Azure DevOps to variable of PowerShell? 如何使用 Azure Devops 将 powershell 列表变量传输到 terraform? - How to transfer a powershell list variable to terraform by using Azure Devops? 在具有Linux容器代理的Azure DevOps上的Powershell脚本中使用环境变量 - Use environment variable in powershell script on Azure DevOps with linux container agent Azure DevOps 条件无法评估 Powershell 设置变量 - Azure DevOps conditional can't evaluate Powershell set-variable 如何在 Azure Devops 发布管道中使用 PowerShell 设置环境变量? - How to set an environment variable with PowerShell in Azure Devops release pipeline? 每个阶段引用不同的变量组 - 环境中每个环境的阶段 - Azure Devops、模板、变量组 - Reference a different Variable group per stage - stage per environment in environments - Azure Devops, template, variable groups
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM