【发布时间】:2018-07-16 17:31:22
【问题描述】:
以下是我编写的变量声明和 power shell 脚本,用于在新构建队列中更新构建变量
声明:
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”。
下一个任务 - 更新程序集信息 -> 我没有得到更新的值。
我错过了什么吗?请帮帮我。
【问题讨论】:
-
ActualRevision 是您在构建定义的变量选项卡中设置的变量吗?
-
@DenverDev 是的。
标签: tfs azure-devops azure-pipelines-build-task