2017-02-22 96 views
1

我们有一个执行自动构建的CI构建服务器,并希望在构件版本中包含当前的冲刺/迭代编号。有没有一个环境变量或简单的方法在构建过程中获取当前的sprint编号? TFS On Permise 2015更新3TFS构建变量当前冲刺TFS 2015

回答

5

没有内置变量来获取当前冲刺,但可以使用REST API。 步骤:

  1. 添加一个PowerShell文件到源控制(例如包含在项目中,并检查在)

代码:

Param(
    [string]$collection, 
    [string]$projectName, 
    [string]$token 
) 
$uri="$collection/$projectName/_apis/work/teamsettings/iterations?`$timeframe=current&api-version=v2.0-preview" 
Write-Output $uri 
$result = Invoke-RestMethod -Uri $uri -Method Get -Headers @{Authorization=("Bearer {0}" -f $token)} 

Write-Output "success" 
Write-Output $result.value.path 

Write-Host "##vso[task.setvariable variable=currentSprint;]$($result.value.path)" 
  • 编辑您的构建定义
  • 单击选项选项卡并选中允许脚本访问OAuth令牌
  • enter image description here

  • 添加PowerShell的生成步骤和指定的PowerShell文件(步骤1)(参数:-collection $(System.TeamFoundationCollectionUri)-projectName $(System.TeamProject) - 标记$(System.AccessToken))
  • enter image description here

    在此之后,电流冲刺值存储在变量currentSprint。