/// <summary> /// Executes the logic for this workflow activity. /// </summary> /// <param name="context">The workflow context.</param> /// <returns>The <see cref="Microsoft.TeamFoundation.Build.Client.IQueuedBuild"/> /// object that is returned after queueing the new build.</returns> protected override IQueuedBuild Execute(CodeActivityContext context) { if (context == null) { throw new ArgumentNullException("context"); } IBuildServer buildServer = context.GetValue(this.BuildServer); IBuildDefinition buildDefinition = context.GetValue(this.BuildDefinition); IBuildRequest buildRequest = buildServer.CreateBuildRequest(buildDefinition.Uri); buildRequest.Priority = context.GetValue(this.Priority); string processParameters = context.GetValue(this.ProcessParameters); if (!string.IsNullOrEmpty(processParameters)) { buildRequest.ProcessParameters = processParameters; } IBuildController buildController = context.GetValue(this.BuildController); if (buildController != null) { buildRequest.BuildController = buildController; } IQueuedBuild queuedBuild = buildServer.QueueBuild(buildRequest); return(queuedBuild); }
/// <summary> /// Executes the logic for this workflow activity. /// </summary> /// <returns>The <see cref="Microsoft.TeamFoundation.Build.Client.IQueuedBuild"/> /// object that is returned after queueing the new build.</returns> protected override IQueuedBuild InternalExecute() { IBuildServer buildServer = this.BuildServer.Get(this.ActivityContext); IBuildDefinition buildDefinition = this.BuildDefinition.Get(this.ActivityContext); IBuildRequest buildRequest = buildServer.CreateBuildRequest(buildDefinition.Uri); buildRequest.Priority = this.Priority.Get(this.ActivityContext); if (Enum.IsDefined(typeof(QueuePriority), buildRequest.Priority) == false) { // Set default value to normal, if no value has been passed. buildRequest.Priority = QueuePriority.Normal; } string processParameters = this.ProcessParameters.Get(this.ActivityContext); if (!string.IsNullOrEmpty(processParameters)) { buildRequest.ProcessParameters = processParameters; } IBuildController buildController = this.BuildController.Get(this.ActivityContext); if (buildController != null) { buildRequest.BuildController = buildController; } IQueuedBuild queuedBuild = buildServer.QueueBuild(buildRequest); return(queuedBuild); }
public bool Execute() { // set up support for logging TaskLoggingHelper loggingHelper = new TaskLoggingHelper(this); // Log Variables loggingHelper.LogMessageFromText("Custom Task QueueBuild Starting", MessageImportance.High); loggingHelper.LogMessageFromText("tfsServer = " + tfsServer, MessageImportance.High); loggingHelper.LogMessageFromText("teamProject = " + teamProject, MessageImportance.High); loggingHelper.LogMessageFromText("buildDefinition = " + buildDefinition, MessageImportance.High); // Get the team foundation server TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsServer); // Get the IBuildServer IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer)); // Get the build definition for which a build is to be queued IBuildDefinition buildDef = buildServer.GetBuildDefinition(teamProject, buildDefinition); // Create variable for queuedBuild and queue the build var queuedBuild = buildServer.QueueBuild(buildDef); loggingHelper.LogMessageFromText("Waiting for newly queued build from Team Project : " + teamProject + " : and Build Definition : " + buildDefinition + " : to complete", MessageImportance.High); loggingHelper.LogMessageFromText("Pinging queuedBuild : " + queuedBuild + " : every 5 seconds to confirm when build is complete", MessageImportance.High); // Wait for the completion of newly queued build - Will ping build every 5 seconds to confirm completion for a max of 5 hours queuedBuild.WaitForBuildCompletion(TimeSpan.FromSeconds(5), TimeSpan.FromHours(5)); loggingHelper.LogMessageFromText("Queued Build : " + queuedBuild.Build.BuildNumber + " has now completed", MessageImportance.High); loggingHelper.LogMessageFromText("Returning to original build", MessageImportance.High); return(true); }
protected override void Execute(CodeActivityContext context) { String[] dirty = context.GetValue(this.TfsProjectAndBuildDefinition); IBuildDetail buildDetail = context.GetValue(this.BuildDetail); var pds = Parse(dirty); //var workspace = buildDetail.BuildDefinition.Workspace; IBuildServer buildServer = buildDetail.BuildServer; foreach (var pd in pds) { try { string message = string.Format("Queue new build \"{0}\"-\"{1}\"", pd.TfsProject, pd.BuildDefinition); context.TrackBuildMessage(message); IBuildDefinition buildDef = buildServer.GetBuildDefinition(pd.TfsProject, pd.BuildDefinition); buildServer.QueueBuild(buildDef); } catch (Exception ex) { string message = string.Format("Queue new build error \"{0}\"-\"{1}\", Exception : \"{2}\"", pd.TfsProject, pd.BuildDefinition, ex.Message); context.TrackBuildWarning(message); } } }
public void RunBuild(string id) { if (BuildList == null) { throw new ApplicationException("builds collection is not initialized"); } var buildToRun = BuildList.Find(b => b.Id == id); if (buildToRun != null) { var queuedBuild = BuildServer.QueueBuild(buildToRun.TFSBuildDefInstance); if (BuildStatusChanged != null) { //need to get fresh build info var details = buildToRun.TFSBuildDefInstance.QueryBuilds(); if (details != null && details.Length == 0) { // build is still in queue var newLastRun = GetBuildRunInfo(details); buildToRun.LastRun = newLastRun; BuildStatusChanged(this, new BuildStatusChangedEventArgs() { BuildDefinitions = new BuildDefinitionItem[] { buildToRun } }); } } } }
static void QueueAllBuildDefinitions(IBuildServer buildServer) { foreach (IBuildDefinition buildDefinition in buildServer.QueryBuildDefinitions("Contoso")) { IBuildRequest request; request = buildDefinition.CreateBuildRequest(); buildServer.QueueBuild(request); } }
public static void QueueBuild(string buildName) { string buildDefinitionInfo = System.Configuration.ConfigurationManager.AppSettings[buildName].ToString(); string projectCollectionUrl = System.Configuration.ConfigurationManager.AppSettings["projectCollectionUrl"]; TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(new Uri(projectCollectionUrl)); IBuildServer buildServer = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer)); string projectName = buildDefinitionInfo.Split(';')[0]; string definitionName = buildDefinitionInfo.Split(';')[1]; IBuildDefinition buildDefinition = buildServer.GetBuildDefinition(projectName, definitionName, QueryOptions.Definitions); buildServer.QueueBuild(buildDefinition); }
public void QueueDefaultSubFolderBuilds() { // if (NodePriority == (int)TeamExplorerNodePriority.Leaf) // return; // just ignore, we should never be here IBuildServer buildServer = GetBuildServer(); foreach (IBuildDefinition buildDef in FindAssociated.AssociatedNodes(CanonicalName, this, separator).Select( item => buildServer.GetBuildDefinition(item.ProjectName, item.Name))) { if (buildDef.Enabled) { buildServer.QueueBuild(buildDef); } } BaseHierarchyNode node = FindAssociated.AssociatedNode("All Build Definitions", this, separator); node.ParentHierarchy.CallMethod("ViewBuilds", node); }
static void QueueAllBuildDefinitions(IBuildServer buildServer) { foreach (IBuildDefinition buildDefinition in buildServer.QueryBuildDefinitions("Contoso")) { IBuildRequest request; request = buildDefinition.CreateBuildRequest(); buildServer.QueueBuild(request); } }