static async Task Main(string[] args) { var devOpsAccessSetting = new DevOpsAccessSetting("<PAT>"); try { var agentManagement = new AgentManagement(devOpsAccessSetting); IList <VstsAgent> agents = await agentManagement.GetAgentsAsync(AgentManagement.IoTEdgeAgentPoolId).ConfigureAwait(false); var agentMatrix = new AgentMatrix(); agentMatrix.Update(agents.Select(IoTEdgeVstsAgent.Create).ToHashSet()); var unmatchedAgents = agentMatrix.GetUnmatchedAgents(); var buildManagement = new BuildManagement(devOpsAccessSetting); var result = await buildManagement.GetLatestBuildsAsync(BuildDefinitionExtension.MasterBranchReporting, "refs/heads/master").ConfigureAwait(false); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public async Task <IActionResult> Index() { var agentManagement = new AgentManagement(new DevOpsAccessSetting(this._appConfig.PersonalAccessToken)); IList <VstsAgent> agents = await agentManagement.GetAgentsAsync(AgentManagement.IoTEdgeAgentPoolId).ConfigureAwait(false); var agentMatrix = new AgentMatrix(); agentMatrix.Update(agents.Select(IoTEdgeAgent.Create).ToHashSet()); var viewModel = new AgentMatrixViewModel { AgentTable = agentMatrix }; List <IoTEdgeAgent> unmatchedAgents = agentMatrix.GetUnmatchedAgents().ToList(); // Image build viewModel.ImageBuild = new ImageBuildViewModel { Group = new AgentDemandSet("Build Images", new HashSet <AgentCapability> { new AgentCapability("build-Image", "true") }), Agents = new List <IoTEdgeAgent>() }; for (int i = unmatchedAgents.Count - 1; i >= 0; i--) { if (unmatchedAgents[i].Match(viewModel.ImageBuild.Group.Capabilities)) { viewModel.ImageBuild.Agents.Add(unmatchedAgents[i]); unmatchedAgents.RemoveAt(i); } } viewModel.UnmatchedAgents = unmatchedAgents; return(this.View(viewModel)); }