我可以在Azure DevOps发布管道中以编程方式为变量设置可覆盖的默认值吗? [英] Can I programmatically set an overridable default value for a variable in an Azure DevOps Release Pipeline?

本文介绍了我可以在Azure DevOps发布管道中以编程方式为变量设置可覆盖的默认值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Azure DevOps发布管道中有一个名为 some_var 的变量.我想在发布时设置默认值.但是我想基于工件放置文件夹中文件的内容以编程方式设置它.但是我仍然希望用户能够在创建发行版时覆盖动态设置的值.

因此,最终用户的行为将是,他们(1)导航到发行版",然后(2)单击新建".该对话框带有 some_var 变量,该变量已经设置为存储在文本文件中的值.但是,由于将变量设置为在运行时可设置,因此他们也可以在单击按钮以创建发行版之前修改变量值.

有什么方法可以动态填充(在创建发行版之前) some_var 值,并且仍然可以让创建该发行版的人在创建时对其进行编辑.

解决方案

对话框出现时,some_var变量已经设置为一个值存储在文本文件中.

我们不支持此开箱即用功能.发布管道变量不能动态在创建发行版之前填充 some_var 值.

可能的解决方法:

您的原始目的是根据工件放置文件夹中文件的内容,以编程方式对其进行设置.因此,我假设您可能具有此版本所依赖的构建管道,而您的实际需求是:

构建管道完成后,发布管道中 some_var 默认值应设置为构建管道中的值.

您可以考虑在发行版本所依赖的构建管道的末尾添加Powershell任务,调用

整个行为是(假设我们要将Build中的buildID传递给Release中的 some_var ):

1.构建管道执行良好,其上一个Powershell任务将 some_var 更新为 some_var = 15 .

2.当我单击 Create release 按钮时,对话框弹出 some_var 变量,该变量已经设置为Build管道 15 中的值.

3.现在,由于 some_var 在发布时启用了可设置,因此我们可以在单击 Create 按钮之前轻松地对其进行修改.

希望它会有所帮助:)

I have a variable called some_var in an Azure DevOps release pipeline. I'd like to set the default at release time. But I want to set it programmatically based on the contents of a file in the artifact drop folder. But I still want the user to be able to overwrite the dynamically set value at the time they're creating the release.

So the end-user behavior would be that they (1) navigate to the Release and (2) click "Create New". The dialog comes up with the some_var variable already set to a value stored in a text file. But, because the variable is set to be settable at runtime, they can also modify the variable value before they click the button to create the release.

Is there any way I can dynamically populate (before the release is created) the some_var value and still make it editable by the person creating the release at crate-time.

解决方案

The dialog comes up with the some_var variable already set to a value stored in a text file.

We don't support this out-of-box feature. The release pipeline variable can't dynamically populate the some_var value before the release is created.

Possible workaround:

Your original purpose is to set it programmatically based on the contents of a file in the artifact drop folder. So I assume you may have a build pipeline which this release depends on, and your actual need is to:

Once the build pipeline is finished, the default value of some_var in release pipeline should set as the value from build pipeline.

You can consider adding a powershell task in the end of build pipeline that release depends on, calling the Definitions-Update rest api in ps script to set the default value of some_var in Release pipeline depending on content of Build pipeline. Similar issue you can check this one.

And if the pipeline variable some_var is settable at release time:

The whole behavior would be (assuming we want to pass the buildID in Build to the some_var in Release):

1.The build pipeline executes well, its last Powershell task updates the some_var to some_var = 15.

2.When I click the Create release button, the dialog comes up with some_var variable already set to a value from Build pipeline 15.

3.Now, because the some_var enables settable at release time, we can easily modify it before clicking the Create button.

Hope it helps :)

这篇关于我可以在Azure DevOps发布管道中以编程方式为变量设置可覆盖的默认值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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