예제 #1
0
        /// <summary>
        /// Gets the latest revision identifier from each project with a trigger method of Polling and pushes the project onto the build queue if there are recent changes.
        /// </summary>
        /// <returns></returns>
        public async Task PollOnceForChangesAsync()
        {
            var projectIds = await _repository.GetProjectsToPollForChanges();

            await _logger.LogInfoAsync($"Checking for changes with {projectIds.Count()} project(s).");

            foreach (var projectID in projectIds)
            {
                await _logger.LogDebugAsync($"Processing project {projectID}...");

                var projectConfigTask = _repository.GetProject(projectID);
                var latestBuildTask   = _repository.GetMostRecentBuildAsync(projectID);

                await Task.WhenAll(projectConfigTask, latestBuildTask);

                var projectConfig = projectConfigTask.Result;
                var latestBuild   = latestBuildTask.Result;
                var codeRepo      = CodeRepositoryFactory.Create(projectConfig);

                var codeStatus = await projectConfig.CheckForNeededBuild(codeRepo, latestBuild);

                if (codeStatus.NeedsBuild == true)
                {
                    await _logger.LogInfoAsync($"Adding project {projectID} to the build queue.");

                    await _queue.EnqueueBuild(new BuildQueueEntry()
                    {
                        BuildQueueID       = Guid.NewGuid(),
                        CreateDateTime     = DateTimeOffset.Now,
                        ProjectID          = projectID,
                        RevisionIdentifier = codeStatus.RevisionIdentifier,
                        BuildNumber        = projectConfig.NextBuildNumber
                    });
                }
            }

            await _logger.LogInfoAsync("Project status check complete.");
        }
예제 #2
0
 public async Task EnqueueBuild(string projectId, [FromBody] BuildQueueEntry entry)
 {
     await _queue.EnqueueBuild(entry);
 }