2017-06-18 52 views
1

禁用我有很多TFS构建高清构建的定义,我试图让与MMD_项目说明仅禁用生成定义。的Team Foundation Server如何提取用于特定项目

$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 
 
\t if(!$buildDefinition.enabled) 
 
    { 
 
     Write-Output $definitionsOverview + 'build definition is disabled' 
 
\t \t # I need process parameter is 
 
    } 
 
}

+0

越来越问题如果循环,这可能是在$ buildDefinition.enabled了Syntex或其他任何东西更多更好的编程? – himanshuk

+0

难道只是一个错字吗?你使用$ definitionUrl来定义,但参数$ buildDefinitionUrl来调用? – Curios

回答

0

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

而构建定义状态保存在“queueStatus”属性时生成定义被禁用或暂停。如果构建定义已启用,则不会有“queueStatus”属性。所以你需要相应地更新你的代码。 enter image description here

+0

我使用API​​2.0,仍然@himanshuk您需要使用API​​1.0查询XMAL建立我还没有获得输出 – himanshuk

+0

。 –

+0

如何使用它,我只看到它的2.0开始 – himanshuk

相关问题