VSTS 嵌套变量 [英] VSTS Nested Variables

查看:14
本文介绍了VSTS 嵌套变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一个级联变量,当设置一个设计时变量时,它会级联到其他变量.这可能吗?我尝试过使用点符号,也尝试过不使用点符号,并且尝试在任务中执行此操作:

I'm trying to accomplish a cascading variable, where when one design time variable is set, it cascades to other variables. Is this possible? I've tried with dot notation, I've tried without dot notation, and I've tried to do it in the task:

我也试过这个任务插件,但是我的代理在 2.0 上并且任务没有运行.

I also tried this task plugin, but my agents are on 2.0 and the task doesn't run.

变量工具箱任务

有什么想法吗?

答案:

您可以在环境级别覆盖这些变量.我将不得不在我的脚本中手动扩展这些变量,然后将它们设置为该脚本中的解析值.

You can override these variables at the environment level. I will have to expand these variables in my script manually and then set them to the resolved values in this script.

推荐答案

可以通过构建期间的日志命令:

  1. 添加 PowerShell 任务

脚本:(如果变量包含.,则需要使用_代替,例如Server.Dev=>Server_Dev)

Script: (Need to use _ instead if the variable contains ., such as Server.Dev=> Server_Dev)

$v= [Environment]::GetEnvironmentVariable("Server_$env:Environment")
Write-Host ("##vso[task.setvariable variable=Server;]$v")

  1. 接下来的任务可以使用对应值的Server变量

这篇关于VSTS 嵌套变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆