Ejemplo n.º 1
0
        public async Task RunAsync(TimeSpan waitPeriodAfterEachUpdate, CancellationToken ct)
        {
            var buildManagement   = new BuildManagement(devOpsAccessSetting);
            var releaseManagement = new ReleaseManagement(devOpsAccessSetting);
            var bugManagement     = new BugManagement(devOpsAccessSetting);

            while (!ct.IsCancellationRequested)
            {
                await ImportVstsBugDataAsync(bugManagement, bugQueries);

                foreach (string branch in this.branches)
                {
                    buildLastUpdatePerBranchPerDefinition.Upsert(
                        branch,
                        await ImportVstsBuildsDataAsync(buildManagement, branch, BuildExtension.BuildDefinitions));
                }

                foreach (string branch in this.branches)
                {
                    await ImportVstsReleasesDataAsync(releaseManagement, branch, ReleaseDefinitionId.E2ETest);
                }

                Console.WriteLine($"Import Vsts data finished at {DateTime.UtcNow}; wait {waitPeriodAfterEachUpdate} for next update.");
                await Task.Delay((int)waitPeriodAfterEachUpdate.TotalMilliseconds);
            }
        }
Ejemplo n.º 2
0
        async Task <IList <VstsBuild> > GetBuildsAndTrackLastUpdatedAsync(BuildManagement buildManagement, BuildDefinitionId buildDefinitionId, string branch)
        {
            Dictionary <BuildDefinitionId, DateTime> buildDefinitionIdToLastUpdate = this.buildLastUpdatePerBranchPerDefinition.GetIfExists(branch);

            if (buildDefinitionIdToLastUpdate == null)
            {
                buildDefinitionIdToLastUpdate = new Dictionary <BuildDefinitionId, DateTime>();
            }

            DateTime          lastUpdate   = buildDefinitionIdToLastUpdate.GetIfExists(buildDefinitionId);
            IList <VstsBuild> buildResults = await buildManagement.GetBuildsAsync(new HashSet <BuildDefinitionId> {
                buildDefinitionId
            }, branch, lastUpdate);

            Console.WriteLine($"Query VSTS builds for branch [{branch}] and build definition [{buildDefinitionId.ToString()}]: last update={lastUpdate} => result count={buildResults.Count}");

            DateTime maxLastChange = DateTime.MinValue;

            foreach (VstsBuild build in buildResults.Where(r => r.HasResult()))
            {
                if (build.LastChangedDate > maxLastChange)
                {
                    maxLastChange = build.LastChangedDate;
                }
            }

            buildDefinitionIdToLastUpdate.Upsert(buildDefinitionId, maxLastChange);
            this.buildLastUpdatePerBranchPerDefinition.Upsert(branch, buildDefinitionIdToLastUpdate);

            return(buildResults);
        }
Ejemplo n.º 3
0
        IEnumerable <ICommandOutput> VerifyVersion()
        {
            var versionFile = _environment.CurrentDirectory.GetFile("version");

            if (Version == null &&
                !versionFile.Exists &&
                _environment.Descriptor.SemanticVersion == null &&
                _environment.Descriptor.Version == null)
            {
                yield return(new PackageVersionMissing());

                yield break;
            }

            Action <string> writer = null;
            Func <string>   reader = null;
            int             build;

            if (BuildCounter != "file" && int.TryParse(Environment.ExpandEnvironmentVariables(BuildCounter), out build))
            {
                reader = () => (build - 1).ToString();
                writer = counter => { };
            }
            _generatedVersion = Version.ToSemVer() ??
                                BuildManagement.GenerateVersion(
                _environment.Descriptor,
                versionFile, reader, writer);
        }
Ejemplo n.º 4
0
        public async Task RunAsync(TimeSpan waitPeriodAfterEachUpdate, CancellationToken ct)
        {
            var buildManagement   = new BuildManagement(devOpsAccessSetting);
            var releaseManagement = new ReleaseManagement(devOpsAccessSetting);
            var bugWiqlManagement = new BugWiqlManagement(devOpsAccessSetting);
            var bugManagement     = new BugManagement(devOpsAccessSetting);

            while (!ct.IsCancellationRequested)
            {
                await ImportVstsBugDataAsync(bugWiqlManagement, bugQueries);

                foreach (string branch in this.branches)
                {
                    foreach (BuildDefinitionId buildDefinitionId in BuildExtension.BuildDefinitions)
                    {
                        IList <VstsBuild> builds = await GetBuildsAndTrackLastUpdatedAsync(buildManagement, buildDefinitionId, branch);

                        Console.WriteLine($"Received {builds.Count} builds");
                        ImportVstsBuildsDataForSpecificDefinitionAsync(builds, buildDefinitionId);
                        await OpenBugsForFailingBuilds(bugManagement, builds, branch, buildDefinitionId);
                    }
                }

                foreach (string branch in this.branches)
                {
                    await ImportVstsReleasesDataAsync(releaseManagement, branch, ReleaseDefinitionId.E2ETest);
                }

                Console.WriteLine($"Import Vsts data finished at {DateTime.UtcNow}; wait {waitPeriodAfterEachUpdate} for next update.");
                await Task.Delay((int)waitPeriodAfterEachUpdate.TotalMilliseconds);
            }
        }
Ejemplo n.º 5
0
    // Start is called before the first frame update
    void Start()
    {
        rend      = GetComponent <Renderer>();
        initColor = rend.material.color;

        buildManagement = BuildManagement.instance;
    }
Ejemplo n.º 6
0
 IDisposable CreateSharedAssemblyInfo()
 {
     if (_generatedVersion != null && _environment.Descriptor.AssemblyInfo.Any())
     {
         _sharedAssemblyInfoFile = BuildManagement.TryGenerateAssemblyInfo(_environment.DescriptorFile, _generatedVersion);
         return(new ActionOnDispose(_sharedAssemblyInfoFile.Delete));
     }
     return(new ActionOnDispose(() => { }));
 }
Ejemplo n.º 7
0
	void Awake()
	{
		if (instance != null)
		{
			Debug.LogError("More than one BuildManagement instance in scene");
			return;	
		}
		instance = this;
	}
Ejemplo n.º 8
0
        public async Task <IActionResult> Index([FromQuery(Name = "branch")] string branch = "master")
        {
            var       buildManagement = new BuildManagement(new DevOpsAccessSetting(this._appConfig.PersonalAccessToken));
            VstsBuild ciBuild         = await buildManagement.GetLatestBuildAsync(BuildDefinitionIds.CI, branch).ConfigureAwait(false);

            return(this.View(
                       new DashboardViewModel
            {
                CIBuild = ciBuild
            }));
        }
Ejemplo n.º 9
0
        void TryGenerateAssemblyInfo()
        {
            if (!GenerateSharedAssemblyInfo)
            {
                return;
            }
            var file = BuildManagement.TryGenerateAssemblyInfo(WrapDescriptorPath);

            if (file != null)
            {
                GeneratedSharedAssemblyInfo = new TaskItem(file.Path.FullPath);
            }
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Index()
        {
            string            masterBranch    = "refs/heads/master";
            var               buildManagement = new BuildManagement(new DevOpsAccessSetting(this._appConfig.PersonalAccessToken));
            IList <VstsBuild> builds          = await buildManagement.GetLatestBuildsAsync(BuildExtension.BuildDefinitions, masterBranch).ConfigureAwait(false);

            return(this.View(
                       new DashboardViewModel
            {
                MasterBranch = new MasterBranch {
                    Builds = builds
                }
            }));
        }
Ejemplo n.º 11
0
        async Task <DateTime> ImportVstsBuildsDataForSpecificDefinitionAsync(
            BuildManagement buildManagement,
            string branch,
            BuildDefinitionId buildDefinitionId,
            DateTime lastUpdate)
        {
            SqlConnection sqlConnection = null;

            try
            {
                sqlConnection = new SqlConnection(this.dbConnectionString);
                sqlConnection.Open();

                IList <VstsBuild> buildResults = await buildManagement.GetBuildsAsync(new HashSet <BuildDefinitionId> {
                    buildDefinitionId
                }, branch, lastUpdate);

                Console.WriteLine($"Query VSTS for branch [{branch}] and build definition [{buildDefinitionId.ToString()}]: last update={lastUpdate} => result count={buildResults.Count}");
                DateTime maxLastChange = lastUpdate;

                foreach (VstsBuild build in buildResults.Where(r => r.HasResult()))
                {
                    UpsertVstsBuildToDb(sqlConnection, build);

                    if (build.LastChangedDate > maxLastChange)
                    {
                        maxLastChange = build.LastChangedDate;
                    }
                }

                return(maxLastChange);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                sqlConnection?.Close();
            }
        }
Ejemplo n.º 12
0
        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());
            }
        }
Ejemplo n.º 13
0
        async Task <Dictionary <BuildDefinitionId, DateTime> > ImportVstsBuildsDataAsync(BuildManagement buildManagement, string branch, HashSet <BuildDefinitionId> buildDefinitionIds)
        {
            Console.WriteLine($"Import VSTS builds from branch [{branch}]");
            Dictionary <BuildDefinitionId, DateTime> lastUpdatePerDefinition = this.buildLastUpdatePerBranchPerDefinition.GetIfExists(branch);

            if (lastUpdatePerDefinition == null)
            {
                lastUpdatePerDefinition = new Dictionary <BuildDefinitionId, DateTime>();
            }

            foreach (BuildDefinitionId buildDefinitionId in buildDefinitionIds)
            {
                DateTime maxLastChange = await ImportVstsBuildsDataForSpecificDefinitionAsync(buildManagement, branch, buildDefinitionId, lastUpdatePerDefinition.GetIfExists(buildDefinitionId));

                lastUpdatePerDefinition.Upsert(buildDefinitionId, maxLastChange);
            }

            return(lastUpdatePerDefinition);
        }
Ejemplo n.º 14
0
 public void Setup()
 {
     this.httpTest        = new HttpTest();
     this.buildManagement = new BuildManagement(new DevOpsAccessSetting(PersonalAccessToken));
 }
Ejemplo n.º 15
0
 void Start()
 {
     buildManagement = BuildManagement.instance;
 }