Пример #1
0
        public async virtual Task <IActionResult> Compare([FromRoute][Required] string environmentFrom, [FromRoute][Required] string environmentTo)
        {
            var sample = new ReleasesSample
            {
                Context = ClientSampleContext.CurrentContext
            };

            var releases = await sample.ListAllReleaseDefinitionsWithEnvironmentsExpanded($"{environmentFrom},{environmentTo}", null);

            var returnReleases = new List <ReleaseInfo> {
            };

            var Exclusions = new [] { "Release Tool", "Clean previous deployments" };

            //additional filtering for temporary
            releases = releases.Where(x => !x.PipelineName.ToLower().Contains("tests") &&
                                      !x.PipelineName.ToUpper().EndsWith("POC") &&
                                      !Exclusions.Any(ex => ex.Equals(x.PipelineName, StringComparison.OrdinalIgnoreCase)))
                       .ToList();

            foreach (var release in releases)
            {
                var temp = release.Environments.ConvertAll(x => new ReleaseEnvironmentInfo
                {
                    DefinitionEnvironmentId = x.DefinitionEnvironmentId,
                    Name          = x.Name,
                    Status        = x.Status == null ? StatusEnum.NotStarted : (StatusEnum)Enum.Parse(typeof(StatusEnum), x.Status),
                    Version       = x.Version,
                    When          = x.When,
                    Who           = x.Who,
                    Rank          = x.Rank,
                    EnvironmentId = x.Id,
                    ReleaseId     = x.ReleaseId,
                });

                var fromVersion = new Version(temp.First().Version);
                var toVersion   = new Version(temp.Last().Version);
                var difference  = fromVersion.CompareTo(toVersion);

                if (difference > 0)
                {
                    temp.Last().Status = StatusEnum.Scheduled;
                }
                else if (difference < 0)
                {
                    temp.First().Status = StatusEnum.Scheduled;
                }

                returnReleases.Add(new ReleaseInfo
                {
                    ProjectName  = release.PipelineName,
                    Environments = temp
                });
            }

            return(new ObjectResult(returnReleases));
        }
Пример #2
0
        public async virtual Task <IActionResult> Get(string environments = null, int?definitionId = null)
        {
            var sample = new ReleasesSample
            {
                Context = ClientSampleContext.CurrentContext
            };

            List <ReleasesSample.ReleaseInfo> releases = await sample.ListAllReleaseDefinitionsWithEnvironmentsExpanded(environments, definitionId);

            List <ReleaseInfo> returnReleases = new List <ReleaseInfo> {
            };

            foreach (var release in releases)
            {
                returnReleases.Add(new ReleaseInfo
                {
                    ProjectName = release.PipelineName,

                    Environments = release.Environments.ConvertAll(x =>
                                                                   new ReleaseEnvironmentInfo
                    {
                        DefinitionEnvironmentId = x.DefinitionEnvironmentId,
                        Name          = x.Name,
                        Status        = x.Status == null ? StatusEnum.Undefined : (StatusEnum)Enum.Parse(typeof(StatusEnum), x.Status),
                        Version       = x.Version,
                        When          = x.When,
                        Who           = x.Who,
                        Rank          = x.Rank,
                        EnvironmentId = x.Id,
                        ReleaseId     = x.ReleaseId,
                    }),
                });
            }

            return(new ObjectResult(returnReleases));
        }