我在 TFS/AzureDevops Build 定义中定义了一个变量(比如 time)
并在我的构建定义中使用 PowerShell 任务分配值。
像,
类型:内联脚本。
内嵌脚本:
$date=$(Get-Date -Format g);
Write-Host "##vso[task.setvariable variable=time]$date"
你可以引用这个 similar example
现在我想在我的发布定义管道中获得这个值。我将此构建定义配置为持续部署到我的发布定义。
我的问题是
我如何获得
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.




