2
A
回答
0
我不认为有内置的活动来链接构建。
我有一个自定义活动,当我需要它们时,用它排队附加构建。
码是如下
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
使用公认Community TFS Build Extensions;有一个QueueBuild
活动可以使用。关于定制研究的指导ALM Rangers' Build Guide。
相关问题
- 1. 如何将多个TFS 2012构建定义链接到一个构建定义
- 2. 如何在TFS 2013中构建成功时启动另一个构建
- 3. 如何从另一个TFS构建中调用TFS构建?
- 4. 批量克隆构建定义TFS 2012
- 5. TFS 2012构建定义/模板 - 如何自动设置构建质量?
- 6. 从另一台PC远程重新启动TFS 2012服务器构建服务
- 7. TFS 2010在TFS 2010中构建定义
- 8. 在Visual Studio 2012/2013/2015中克隆TFS构建定义?
- 9. TFS 2012的滚动构建版本比定义的版本早
- 10. TFS 2015构建定义来查找另一个构建的构件位置
- 11. Tfs构建定义
- 12. 什么是TFS Build 2012中构建定义的`build agent folder` $(SourceDir)?
- 13. 如何复制TFS 2010构建定义?
- 14. 在TFS 2012中删除一个构建控制器
- 15. TFS 2012构建不部署
- 16. 在TFS 2010中编辑构建定义
- 17. 如何使用Laika42 Build Definition Extension工具恢复tfs 2012中的构建定义?
- 18. TFS构建 - PowerShell或自定义活动?
- 19. 如何在TFS构建报告中创建自定义部分?
- 20. 如何在初始构建失败后启动CodeClimate上的另一个构建?
- 21. 使用TFS 2012构建Visual COBOL 2012
- 22. 如何在TFS 2012构建过程模板的自定义活动中运行其他活动?
- 23. 如何强制构建在TFS中启动?
- 24. TFS构建定义问题
- 25. 在启动后命名TFS构建
- 26. 从另一个构建(条件)在TFS触发构建2015年
- 27. TFS 2010构建定义在解决方案中构建一个项目
- 28. 在一个单一的构建定义TFS 2010
- 29. 基于构建定义更改配置TFS 2012
- 30. 如何在另一个网站上构建自定义端点?