如何在变量组中设置变量的值

如何在变量组中设置变量的值

本文介绍了Azure DevOps:如何在变量组中设置变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试覆盖Azure DevOps中变量组中变量的值,但它不起作用.它总是显示原始值.

我写了我的Powershell脚本,如以下链接所示:

  • 我在 Power Shell脚本任务中编写了以下脚本.

     写入主机原始BPOwner = $(BPOwner)"写主机将BPOwner的值更改为Bright Ran"写主机"## vso [task.setvariable variable = BPOwner;] Bright Ran"写主机"New BPOwner = $(BPOwner)" 

    但是,在Build中,它始终显示原始值,并且永远不会更改为我要设置的值.

    您能否建议我如何在构建管道中设置此值?

    解决方案

    新值仅在下一个任务中可用,而在您更改值时不在同一任务中可用.例如,我用 Write-Host"New BPOwner = $(BPOwner)" 添加了另一个PS任务:

    上面是记录命令 ## vso [task.setvariable variable] 的行为,不仅是变量组.

    I am trying to overwrite the value of the variable from Variable Group in Azure DevOps and it's not working. It's always showing the original value.

    I wrote my Powershell scripts as shown by these links:

    I added the Variable Group and Link it in my Build pipeline.

    I wrote the following scripts in Power Shell Script task.

    Write-Host "Original BPOwner = $(BPOwner)"
    
    Write-Host "Changing value of BPOwner to Bright Ran"
    Write-Host "##vso[task.setvariable variable=BPOwner;]Bright Ran"
    
    Write-Host "New BPOwner = $(BPOwner)"
    

    However, in the Build, it's always showing the original value and it's never changed to the value I want to set.

    Could you please suggest me how I could set this value in the Build Pipeline?

    解决方案

    The new value available only in the next tasks, not in the same task when you change the value. for example, I added another PS task with Write-Host "New BPOwner = $(BPOwner)":

    The above it's the behavior of the logging command ##vso[task.setvariable variable] and not only to the variable group.

    这篇关于Azure DevOps:如何在变量组中设置变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 19:10