gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 14:08:38 26 4
gpt4 key购买 nike

我在 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.

关于tfs - 如何从构建到发布管道获取 TFS/AzureDevOps 中的变量值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52568195/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com