/// <summary> /// Executes the logic for this workflow activity. /// </summary> /// <returns>The <see cref="Microsoft.TeamFoundation.Build.Client.IBuildController"/> /// that is specified.</returns> protected override IBuildController InternalExecute() { IBuildServer buildServer = this.BuildServer.Get(this.ActivityContext); string buildControllerName = this.BuildControllerName.Get(this.ActivityContext); return(buildServer.GetBuildController(buildControllerName)); }
private IBuildController GetBuildController(IBuildServer buildServer, string buildController) { if (string.IsNullOrEmpty(buildController)) { return(buildServer.QueryBuildControllers(false).First()); } return(buildServer.GetBuildController(buildController)); }
/// <summary> /// Executes the logic for this workflow activity. /// </summary> /// <param name="context">The workflow context.</param> /// <returns>The <see cref="Microsoft.TeamFoundation.Build.Client.IBuildController"/> /// that is specified.</returns> protected override IBuildController Execute(CodeActivityContext context) { if (context == null) { throw new ArgumentNullException("context"); } IBuildServer buildServer = context.GetValue(this.BuildServer); string buildControllerName = context.GetValue(this.BuildControllerName); return(buildServer.GetBuildController(buildControllerName)); }
public static void BuildDefinition(string collection, string teamProject, string buildController, string buildName, string buildDescription, string user, string password) { string teamProjectPath = "$/" + teamProject; // Get a reference to our Team Foundation Server. TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(collection), new System.Net.NetworkCredential(user, password)); tpc.EnsureAuthenticated(); VersionControlServer versionControl = tpc.GetService <VersionControlServer>(); IBuildServer buildServer = tpc.GetService <IBuildServer>(); //Create build definition and give it a name and desription IBuildDefinition buildDef = buildServer.CreateBuildDefinition(teamProject); buildDef.Name = buildName; buildDef.Description = buildDescription; buildDef.ContinuousIntegrationType = ContinuousIntegrationType.Individual; //CI //Controller and default build process template buildDef.BuildController = buildServer.GetBuildController(buildController); var defaultTemplate = buildServer.QueryProcessTemplates(teamProject).First(p => p.TemplateType == ProcessTemplateType.Default); buildDef.Process = defaultTemplate; buildDef.Workspace.AddMapping(teamProjectPath, "$(SourceDir)", WorkspaceMappingType.Map); buildDef.Workspace.AddMapping(teamProjectPath + "/Drops", "$(SourceDir)", WorkspaceMappingType.Cloak); //What to build string pattern = "$/*.sln"; var lists = versionControl.GetItems(pattern, VersionSpec.Latest, RecursionType.Full, DeletedState.NonDeleted, ItemType.File); var processParams = new Dictionary <string, string[]>(); if (lists.Items.Any()) { var list = lists.Items .Select(i => i.ServerItem) .ToList(); processParams.Add("ProjectsToBuild", list.ToArray()); } processParams.Add("ConfigurationsToBuild", new[] { "Any CPU|Debug" }); buildDef.ProcessParameters = SerializeParams(processParams); buildDef.RetentionPolicyList.Clear(); buildDef.AddRetentionPolicy(BuildReason.Triggered, BuildStatus.Succeeded, 10, DeleteOptions.All); buildDef.AddRetentionPolicy(BuildReason.Triggered, BuildStatus.Failed, 10, DeleteOptions.All); buildDef.AddRetentionPolicy(BuildReason.Triggered, BuildStatus.Stopped, 1, DeleteOptions.All); buildDef.AddRetentionPolicy(BuildReason.Triggered, BuildStatus.PartiallySucceeded, 10, DeleteOptions.All); //Lets save it buildDef.Save(); }
private IBuildController GetBuildController(IBuildServer buildServer, string buildController) { if (string.IsNullOrEmpty(buildController)) return buildServer.QueryBuildControllers(false).First(); return buildServer.GetBuildController(buildController); }
public void TestConnection(BuildController b) { IBuildController bc = buildSrv.GetBuildController(b.Uri, false); buildSrv.TestConnectionForBuildController(bc); }