public static string GetBuildAgent(IBuildDetail build) { if (build != null) { build.RefreshAllDetails(); foreach (var child in build.Information.Nodes) { string AgentName = ShowChild(child, 1); if (!string.IsNullOrEmpty(AgentName)) { return AgentName; } } } return string.Empty; }
protected override string Execute(CodeActivityContext context) { // Obtain the runtime value of the Text input argument string text = context.GetValue(this.OutputFile); string filename = context.GetValue(this.FileName); string configFilePath = context.GetValue(this.ServerName); //http://team:8080/tfs/WebSites /* * string BaseTFSDir = bldConfig.Rules["BaseTFSDir"].Value; * string BaseDeploymentDir = bldConfig.Rules["BaseDeploymentDir"].Value; * string BuildDeploymentDir = bldConfig.Rules["BuildDeploymentDir"].Value; */ IBuildDetail bldD = context.GetValue(BuildDetail); TfsTeamProjectCollection tfs = bldD.BuildServer.TeamProjectCollection; ///new TfsTeamProjectCollection(new Uri(context.GetValue(ServerName) as string));// VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); bldD.RefreshAllDetails(); //commensurate the zip deployment with the current build TeamFoundationIdentity id; tfs.GetAuthenticatedIdentity(out id); //ZipDeployer.UID = (id == null)?"UnknownUser" : id.UniqueName; //var changesets = InformationNodeConverters.GetAssociatedChangesets(bldD);//.OrderBy(a=> a.ChangesetId); var changesets = context.GetValue(this.AssocSets); TFSDeployerController deploy = new TFSDeployerController(tfs.Uri.AbsoluteUri, configFilePath, bldD.BuildNumber); return(deploy.deploy(tfs, changesets)); /**/ //if (string.IsNullOrEmpty(text)) // throw new ArgumentException("Please specify a path"); //String.Format("{0}@$/{1}", LabelName, BuildDetail.BuildDefinition.TeamProject) }
internal BuildDetailSectionStatus Initialize(IBuildDetail bd) { var result = new BuildDetailSectionStatus(); bd.RefreshAllDetails(); var workItemsOpened = new StringBuilder(); List <IBuildInformationNode> workItemsOpenedNodes = bd.Information.GetNodesByType("OpenedWorkItem"); workItemsOpenedNodes.ForEach(node => { workItemsOpened.AppendFormat("{0} ({1}/{2}) ; ", node.Fields["WorkItemId"], node.Fields["Status"], node.Fields["AssignedTo"]); }); List <IBuildInformationNode> steps = bd.Information.GetNodesByType("BuildStep"); IBuildInformationNode buildCompletedNode = steps.Find(node => { return(node.Fields["Name"] == "BuildCompleted"); }); if (buildCompletedNode != null) { result.Success = (buildCompletedNode.Fields["Status"].ToLower() == "succeeded"); result.Message = buildCompletedNode.Fields["Message"]; } else { result.Success = false; result.Message = string.Empty; } // build name link label var control_BuildName = new LinkLabel(); control_BuildName.BackColor = Color.Transparent; control_BuildName.Text = bd.BuildNumber; control_BuildName.AutoSize = true; control_BuildName.Tag = bd.DropLocation; control_BuildName.Click += BuildName_Click; // log file link label var control_Log = new LinkLabel(); control_Log.BackColor = Color.Transparent; control_Log.Text = bd.LogLocation; control_Log.AutoSize = true; control_Log.Click += LogFile_Click; var itemValues = new List <object> { control_BuildName, bd.RequestedBy, bd.BuildDefinition.TeamProject, bd.BuildDefinition.Name, string.Empty, //bd.BuildAgent.Name, string.Empty, //bd.CommandLineArguments, bd.StartTime.ToString(), bd.FinishTime.ToString(), bd.LastChangedBy, bd.LastChangedOn.ToString(), bd.Quality, workItemsOpened.ToString(), bd.SourceGetVersion, control_Log }; this.lvItems.BeginUpdate(); try { this.lvItems.Controls.Clear(); this.table.Rows.Clear(); for (int i = 0; i < this.itemNames.Length; i++) { string itemName = this.itemNames[i]; var itemValue = (itemValues[i] is string?itemValues[i] : string.Empty) as string; var newRow = new Row(); newRow.Cells.Add(new Cell(itemName)); var cell = new Cell(itemValue); newRow.Cells.Add(cell); this.table.Rows.Add(newRow); if (itemValues[i] is Control) { Rectangle cellRect = this.lvItems.CellRect(cell); var control = itemValues[i] as Control; this.lvItems.Controls.Add(control); control.Location = new Point(cellRect.X, cellRect.Y - 1); control.BringToFront(); } } } finally { this.lvItems.EndUpdate(); Rectangle rectangle = this.lvItems.ColumnRect(1); this.ValueColumnLeftPos = rectangle.Left + 14; } #region debug // Debug.WriteLine(new string('-', 120)); // foreach (var node in bd.Information.Nodes) // { // Debug.WriteLine(string.Format("Type: {0}", node.Type)); // foreach (var field in node.Fields) // { // Debug.WriteLine(string.Format(" Field: {0} | Value: {1}", field.Key, field.Value)); // } // Debug.WriteLine(new string('=', 120)); // } #endregion return(result); }
internal BuildDetailSectionStatus Initialize(IBuildDetail bd, ImageList imageList) { var result = new BuildDetailSectionStatus(); this.imageList = imageList; bd.RefreshAllDetails(); List <IBuildInformationNode> stepsNodes = BuildStepsNodes(bd); int successedCount = 0; this.lvItems.BeginUpdate(); try { this.lvItems.Controls.Clear(); this.table.Rows.Clear(); stepsNodes.ForEach(node => { var newRow = new Row(); //newRow.Height = 20; // icon cell var iconCell = new Cell(); newRow.Cells.Add(iconCell); // Build step message cell string message = node.Fields["Message"]; var messageCell = new Cell(message); newRow.Cells.Add(messageCell); // Completed On cell string finishTime = node.Fields["FinishTime"]; DateTime completedOn = DateTime.Parse(finishTime); var completedOnCell = new Cell(completedOn.ToString()); newRow.Cells.Add(completedOnCell); this.table.Rows.Add(newRow); // icon cell image string status = node.Fields["Status"]; bool successed = status.ToLower() == "succeeded"; LinkLabel iconControl = CreateIcon(successed); this.lvItems.Controls.Add(iconControl); Rectangle iconCellRect = this.lvItems.CellRect(iconCell); iconControl.Location = new Point(iconCellRect.X, iconCellRect.Y + 1); iconControl.BringToFront(); if (successed) { successedCount++; } }); result.Success = successedCount == stepsNodes.Count; result.Message = string.Format("{0} succeeded, {1} failed", successedCount, stepsNodes.Count - successedCount); } finally { this.lvItems.EndUpdate(); } return(result); }