2010-06-07 23 views
6

Tập lệnh xây dựng hàng loạt hiện có của chúng tôi chứa URL để lấy sản phẩm xây dựng mới nhất (của một định nghĩa xây dựng khác) từ.Làm thế nào để có được tạo phẩm xây dựng cuối cùng trong bản vẽ TFS build?

Làm cách nào để có thể truy cập thư mục thả xây dựng nhỏ nhất của TFS Team Build?

Tôi đang tìm một cái gì đó để truy cập mới nhất \ buildserver \ builddrop \ Project-2010MMDD.N \

Trả lời

4

Sử dụng API, bạn có thể có được vị trí thả từ việc xây dựng. Mã bên dưới nhận được bản dựng mới nhất cho một dự án cụ thể và trả về danh sách thả xuống.

public string DropFolder(TeamFoundationServer tfs, string teamProject, string buildName) 
{ 
    IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer)); 

    IBuildDetailSpec buildDetailSpec = buildServer.CreateBuildDetailSpec(teamProject, buildName); 

    buildDetailSpec.MaxBuildsPerDefinition = 1; 
    buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending; 
    buildDetailSpec.Status = BuildStatus.Failed | BuildStatus.PartiallySucceeded | BuildStatus.Stopped | BuildStatus.Succeeded; 

    IBuildQueryResult results = buildServer.QueryBuilds(buildDetailSpec); 

    if (results.Failures.Length != 0) 
    { 
     throw new ApplicationException("this needs to go away and be handled more nicely"); 
    } 

    if (results.Builds.Length == 1) 
    { 
     results.Builds[0].DropLocation; 
    } 
    else 
    { 
     return null; 
    } 
} 
+1

Ngoài ra, nếu viết một ứng dụng tiện ích nhỏ để thực hiện việc này không có trong thẻ thì cùng một API sẽ được hiển thị với PowerShell. – Robaticus

Các vấn đề liên quan