gpt4 book ai didi

tfs - VSTS 构建变量更新在队列新构建中不起作用

转载 作者:行者123 更新时间:2023-12-03 12:39:21 26 4
gpt4 key购买 nike

下面是我编写的变量声明和 power shell 脚本,用于在队列新构建中更新构建变量

声明:

enter image description here

Power shell 脚本:

$fileData = Get-Content -Path C:\builds\agent\PreviousRevisionUpdate.txt
$temp=$fileData[1]

##vso[task.setvariable variable=ActualRevision;]$temp
Write-Host "$temp - $env:ActualRevision"

输出:

2018-02-06T15:29:19.6035251Z ##[section]Starting: Actual Build Number Update
2018-02-06T15:29:19.6035251Z ==============================================================================
2018-02-06T15:29:19.6035251Z Task : PowerShell
2018-02-06T15:29:19.6035251Z Description : Run a PowerShell script
2018-02-06T15:29:19.6035251Z Version : 1.2.3
2018-02-06T15:29:19.6035251Z Author : Microsoft Corporation
2018-02-06T15:29:19.6035251Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
2018-02-06T15:29:19.6035251Z ==============================================================================
2018-02-06T15:29:19.6095263Z ##[command]. 'C:\builds\agent\_work\_temp\dd262af4-0863-4f8d-a14e-1d9ea50b4c72.ps1'
2018-02-06T15:29:20.1186281Z 11 - 1
2018-02-06T15:29:20.1386321Z ##[section]Finishing: Actual Build Number Update

从上面的输出来看,它仍然将变量值显示为“1”而不是“11”。

下一个任务 - 更新程序集信息 -> 我没有获得更新值的地方。

enter image description here

我错过了什么吗??请帮帮我。

最佳答案

是的,您遗漏了一些重要的东西,实际上值已更新。但是,它只能用作后续任务,不能用于您更新的任务,这就是为什么您的 powershell 脚本的输出仍然将变量值显示为“1”而不是“11”。

Sets a variable in the variable service of taskcontext. The first task can set a variable, and following tasks are able to use the variable. The variable is exposed to the following tasks as an environment variable.

Source Link: Logging Commands

对于测试,您可以在更新构建变量的任务之后添加一个 powershell 脚本,如下所示:

Write-Host "After: - $env:ActualRevision"

从结果可以看出,ActualRevision 的值在以下任务中已更改为 11。

enter image description here


更新:

我的脚本:

$temp=11
Write-Host "Before: $temp - $env:ActualRevision"


Write-Host ##vso[task.setvariable variable=ActualRevision;]$temp

Write-Host "After: $temp - $env:ActualRevision"

测试脚本(另一个任务):

Write-Host "After: - $env:ActualRevision"

关于tfs - VSTS 构建变量更新在队列新构建中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48646642/

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