在 TFS RMI 任务中设置变量

Setting variables in TFS RMI tasks

TFS 发布管理有一个变量的概念。它们是在设计时在发布定义中设置的。有没有办法让任务更改变量以便其他任务看到更改?

WindowsSET命令只影响cmd.exe当前执行实例的环境,不影响封闭进程的环境。

在工作文件夹中的临时文件中一步步传递信息是可能的,但是很粗糙。

我相信是的。我没有对此进行测试,但请看一下这个 VSO 构建任务:

https://marketplace.visualstudio.com/items?itemName=jessehouwing.jessehouwing-vsts-variable-tasks

它有一个可以设置变量的任务。这是它调用的特定 powershell 脚本:

https://github.com/jessehouwing/vsts-variable-tasks/blob/master/vsts-variable-set/vsts-variable-set.ps1

第 22 行:

Write-Host "##vso[task.setvariable variable=$($VariableName);]$Value"

更新:
从那以后,我在这里找到了 Microsoft 文档:
https://github.com/Microsoft/vsts-tasks/blob/master/docs/authoring/commands.md
具体来说:

vso[task.setvariable]value

variable=variable name (Required) issecret=true (Optional) Sets a variable in the variable service of taskcontext. The first task can set a variable, and following tasks are able to use the variable. The variable is exposed to the following tasks as an environment variable. When issecret is set to true, the value of the variable will be saved as secret and masked out from log. Secret variables are not passed into tasks as environment variables and must be passed as inputs. Examples:

##vso[task.setvariable variable=testvar;]testvalue

##vso[task.setvariable variable=testvar;issecret=true;]testvalue