2014-09-19 6 views

답변

0

빌드를 연결하는 작업이 내장되어 있다고 생각하지 않습니다.

필자는 추가 빌드를 필요할 때 대기열에 추가하는 사용자 지정 활동이 있습니다.

코드는 잘 Community TFS Build Extensions를 설립

using Microsoft.TeamFoundation.Build.Client; 
using Microsoft.TeamFoundation.Build.Workflow; 
using Microsoft.TeamFoundation.Client; 
using System; 
using System.Activities; 
using System.Collections.Generic; 

namespace BuildTasks.Activities 
{ 
    // Queue a new build from the same Team Project. 
    [BuildActivity(HostEnvironmentOption.Agent)] 
    public sealed class QueueNewBuildwithParam : CodeActivity 
    { 
     // The Team Project that the build definition belongs to. 
     [RequiredArgument] 
     public InArgument<IBuildDetail> BuildDetail { get; set; } 

     // The build definition to queue 
     [RequiredArgument] 
     public InArgument<String> BuildDefinition { get; set; } 

     // The ParamName 
     [RequiredArgument] 
     public InArgument<String> ParamName { get; set; } 

     // The Param Value 
     [RequiredArgument] 
     public InArgument<String> ParamValue { get; set; } 

     protected override void Execute(CodeActivityContext context) 
     { 
      // Obtain the runtime value of the input arguments 
      string buildDefinition = context.GetValue(this.BuildDefinition); 
      IBuildDetail buildDetail = context.GetValue(this.BuildDetail); 
      string paramValue = context.GetValue(this.ParamValue); 
      string paramName = context.GetValue(this.ParamName); 


      // Obtain the Team Project for the current build definition. 
      string tfsProject = buildDetail.BuildDefinition.TeamProject; 

      string configurationServerUri = buildDetail.BuildServer.TeamProjectCollection.Uri.ToString(); 

      TfsTeamProjectCollection server = new TfsTeamProjectCollection(new Uri(configurationServerUri)); 
      server.EnsureAuthenticated(); 
      IBuildServer buildServer = (IBuildServer)server.GetService(typeof(IBuildServer)); 
      IBuildDefinition buildDef = buildServer.GetBuildDefinition(tfsProject, buildDefinition); 
      IBuildRequest request = buildDef.CreateBuildRequest(); 
      request.ProcessParameters = UpdateBuildDefinitionParam(buildDef.ProcessParameters, paramName, paramValue); 
      buildServer.QueueBuild(request); 
     } 

     private static string UpdateBuildDefinitionParam(string processParameters, string param, string newValue) 
     { 
      IDictionary<String, Object> paramValues = WorkflowHelpers.DeserializeProcessParameters(processParameters); 
      paramValues[param] = newValue; 
      return WorkflowHelpers.SerializeProcessParameters(paramValues); 
     } 
    } 
} 
1

를 사용하여 다음과 같이이다; 사용할 수있는 액티비티는 QueueBuild입니다. 맞춤 설정에 대한 안내는 ALM Rangers' Build Guide을 참조하십시오.

관련 문제