【问题标题】:Team foundation server how to extract build definitions disabled for particular projectTeam Foundation 服务器如何提取为特定项目禁用的构建定义
【发布时间】:2017-11-20 21:31:45
【问题描述】:

我在 TFS 中有很多构建定义,我尝试只获取用 MMD_ 项目声明的禁用构建定义。

$baseUrl = "https://tfs.myTFS.net/tfs"
$targetCollection = "DefaultCollection"
$targetProject = "MMD"
# Get an overview of all build definitions in this team project
$definitionsOverviewUrl = "$baseUrl/$targetCollection/$targetProject/_apis/build/Definitions"
$definitionsOverviewResponse = Invoke-WebRequest -UseDefaultCredentials -Uri $definitionsOverviewUrl
$definitionsOverview = (ConvertFrom-Json $definitionsOverviewResponse.Content).value
# Process all builds that have MMD in their name and want only disabled build def seperated from MMD_
foreach($definitionEntry in ($definitionsOverview | Where-Object { $_.name -like '*MMD_*' }))
{
    $definitionUrl = $definitionEntry.url
    $response = Invoke-WebRequest $buildDefinitionUrl -UseDefaultCredentials
    $buildDefinition = [Newtonsoft.Json.JsonConvert]::DeserializeObject($response.Content)
 #check whether source settings are null or not 
	if(!$buildDefinition.enabled)
    {
        Write-Output $definitionsOverview + 'build definition is disabled'
		# I need process parameter is 
    }
}

【问题讨论】:

  • 在 if 循环中遇到问题,$buildDefinition.enabled 语法或其他更好编程的东西可能是什么?
  • 会不会是打字错误?你用 $definitionUrl 来定义,但是参数 $buildDefinitionUrl 来调用?

标签: powershell tfs build


【解决方案1】:

我假设您正在尝试查询 XAML 构建定义,因为禁用构建定义选项仅在 XAML 构建系统中可用。请确保您使用的是Build API 1.0,因为 API 2.0 适用于新的 vNext 构建系统。所以在$definitionsOverviewUrl中,添加?api-version=1.0

当构建定义为禁用或暂停时,构建定义状态保存在“queueStatus”属性中。如果启用了构建定义,则不会有“queueStatus”属性。所以你需要相应地更新你的代码。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-04-28
  • 1970-01-01
  • 1970-01-01
  • 2016-06-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多