如何从构建到发布管道获取 TFS/AzureDevOps 中的变量值?

How to get the variable value in TFS/AzureDevOps from Build to Release Pipeline?

我在 TFS/AzureDevops 构建定义中定义了一个变量(比如 time) 并在我的构建定义中使用 PowerShell 任务分配值。

喜欢,

类型: 内联脚本。

内联脚本:

$date=$(Get-Date -Format g);
Write-Host "##vso[task.setvariable variable=time]$date"

可以参考这个

现在我想在我的发布定义管道中获取这个值。我将此构建定义配置为持续部署到我的发布定义。

我的问题是

如何使用其他变量在我的发布定义中获取 time 的值?这可能吗?

没有将变量从 Build 传递到 Release 的正式方法。实现此目的的唯一方法是将值存储在文件中(json、xml、yaml,你有什么)并将其作为构建工件附加。这样你就可以读取版本中的文件并再次设置变量。

Martin Hinshelwood 似乎已经对这个问题感到沮丧,turned that functionality into an extension for Azure DevOps Pipelines

Tasks included

  • Variable Save Task - During your build you can save the variables to a json file stored with your other build assets
  • Variable Load Task - During your Release you can load the saved variables and gain access to them.