/// <summary> /// Add a text node to the build log /// </summary> /// <param name="text">Display text</param> /// <param name="parent">Parent node in the build log</param> /// <returns>The new node containing the supplied text</returns> protected static IBuildInformationNode AddTextNode(string text, IBuildInformationNode parent) { IBuildInformationNode childNode = parent.Children.CreateNode(); childNode.Type = parent.Type; childNode.Fields.Add("DisplayText", text); childNode.Save(); return(childNode); }
private void ChangeBuildAssigment(string teamProject, WorkItem workItem, string buildNumber, bool removeAction) { IBuildDetail buildDetail = Context.GetBuild(teamProject, buildNumber); if (buildDetail == null) { return; } try { List <IBuildInformationNode> nodes = buildDetail.Information.GetNodesByType("AssociatedWorkItem"); IBuildInformationNode associatedWI_Node = nodes.Find(node => { return(node.Fields["WorkItemUri"] == workItem.Uri.ToString()); }); if (removeAction) { if (associatedWI_Node != null) { associatedWI_Node.Delete(); } } else { if (associatedWI_Node == null) { IBuildInformationNode node = buildDetail.Information.CreateNode(); node.Type = "AssociatedWorkItem"; node.Fields[CoreField.Title.ToString()] = workItem.Title; node.Fields[CoreField.AssignedTo.ToString()] = workItem.Fields[CoreField.AssignedTo].Value as string; node.Fields["WorkItemUri"] = workItem.Uri.ToString(); node.Fields["Status"] = workItem.State; node.Fields["WorkItemId"] = workItem.Id.ToString(); node.Save(); } } } catch (Exception e) { MessageBox.Show( string.Format("Changing build assigment for workitem id: {0} ('{1}') failed, message: {2}", workItem.Id, workItem.Title, e.Message), "Change build assigment", MessageBoxButtons.OK, MessageBoxIcon.Error); } }