示例#1
0
 public static Project ToProject(this DashboardItemResource dashboardItem, DeploymentTask currentDeploymentTask, DeploymentTask previousDeploymentTask)
 {
     return(new Project()
     {
         Id = dashboardItem.ProjectId,
         Name = $"Deploying {currentDeploymentTask.ProjectName} to {currentDeploymentTask.EnvironmentName}",
         Activity = ((TaskState)dashboardItem.State).ToActivity(),
         LastBuildStatus = ((TaskState)previousDeploymentTask.TaskResource.State).ToLastBuildStatus(),
         LastBuildLabel = previousDeploymentTask.ReleaseVersion,
         LastBuildTime = previousDeploymentTask.TaskResource.CompletedTime?.DateTime ?? DateTime.Now,
         WebUrl = dashboardItem.Links["Task"]
     });
 }
 /// <summary>
 /// Converts a <see cref="DashboardItemResource"/> to a <see cref="DeploymentResult"/>.
 /// </summary>
 /// <param name="item">The item to convert.</param>
 /// <param name="dashboard">The dashboard containing all project and environment information.</param>
 /// <param name="status">The deployment status to set.</param>
 /// <returns>A new deployment result.</returns>
 public static DeploymentResult ToDeploymentResult(this DashboardItemResource item, DashboardResource dashboard, DeploymentStatus status)
 {
     return(new DeploymentResult
     {
         Status = status,
         ErrorMessage = item.ErrorMessage,
         Version = item.ReleaseVersion,
         Project = dashboard.Projects.Where(p => p.Id == item.ProjectId).Select(p => p.ToProject()).SingleOrDefault(),
         Environment = dashboard.Environments.Where(e => e.Id == item.EnvironmentId).Select(e => e.ToDeploymentEnvironment()).SingleOrDefault(),
         TaskId = item.TaskId,
         DeploymentId = item.DeploymentId,
         EventTime = item.CompletedTime ?? DateTimeOffset.Now,
     });
 }
 /// <summary>
 /// Converts a <see cref="DashboardItemResource"/> to a <see cref="DeploymentResult"/>.
 /// </summary>
 /// <param name="item">The item to convert.</param>
 /// <param name="projects">A list of projects.</param>
 /// <param name="environments">A list of environments.</param>
 /// <param name="status">The deployment status to set.</param>
 /// <returns>A new deployment result.</returns>
 public static DeploymentResult ToDeploymentResult(this DashboardItemResource item, IEnumerable <Project> projects, IEnumerable <DeploymentEnvironment> environments, DeploymentStatus status)
 {
     return(new DeploymentResult
     {
         Status = status,
         ErrorMessage = item.ErrorMessage,
         Version = item.ReleaseVersion,
         Project = projects.Where(p => p.ProjectId == item.ProjectId).SingleOrDefault(),
         Environment = environments.Where(e => e.EnvironmentId == item.EnvironmentId).SingleOrDefault(),
         TaskId = item.TaskId,
         DeploymentId = item.DeploymentId,
         EventTime = item.CompletedTime ?? DateTimeOffset.Now,
     });
 }
        public DashboardResource GetDashboard()
        {
            DashboardItemResource build1 = GetBuild("1", BuildOneStatus, BuildOneLastUpdate);
            DashboardItemResource build2 = GetBuild("2", BuildTwoStatus, BuildTwoLastUpdate);
            DashboardItemResource build3 = GetBuild("3", BuildThreeStatus, BuildThreeLastUpdate);

            //DashboardItemResource build4 = GetBuild("3", TaskState.Executing, DateTime.Now, true);
            //DashboardItemResource build5 = GetBuild("3", TaskState.Executing, DateTime.Now, true, true);

            return(new DashboardResource
            {
                Projects = new List <DashboardProjectResource>
                {
                    new DashboardProjectResource {
                        Id = "1", Name = "WebServices.ReferenceDataService.Dep"
                    },
                    new DashboardProjectResource {
                        Id = "2", Name = "WebServices.Admin.Dep"
                    },
                    new DashboardProjectResource {
                        Id = "3", Name = "Business"
                    },
                },
                Environments = new List <DashboardEnvironmentResource>
                {
                    new DashboardEnvironmentResource {
                        Id = "1", Name = "AsmProj-ST"
                    },
                    new DashboardEnvironmentResource {
                        Id = "2", Name = "AsmProj-SIT"
                    },
                    new DashboardEnvironmentResource {
                        Id = "3", Name = "AsmProj-UAT"
                    },
                },
                Items = new List <DashboardItemResource>
                {
                    build1,
                    build2,
                    build3,
                    //build4,
                    // build5,
                },
                PreviousItems = new List <DashboardItemResource>
                {
                }
            });
        }
        static void LogDeploymentInfo(ICommandOutputProvider commandOutputProvider,
                                      DashboardItemResource dashboardItem,
                                      ReleaseResource release,
                                      ChannelResource channel,
                                      IDictionary <string, string> environmentsById,
                                      IDictionary <string, string> projectedById,
                                      IDictionary <string, string> tenantsById)
        {
            var nameOfDeploymentEnvironment = environmentsById[dashboardItem.EnvironmentId];
            var nameOfDeploymentProject     = projectedById[dashboardItem.ProjectId];

            commandOutputProvider.Information(" - Project: {Project:l}", nameOfDeploymentProject);
            commandOutputProvider.Information(" - Environment: {Environment:l}", nameOfDeploymentEnvironment);
            if (!string.IsNullOrEmpty(dashboardItem.TenantId))
            {
                var nameOfDeploymentTenant = GetNameOfDeploymentTenant(tenantsById, dashboardItem.TenantId);
                commandOutputProvider.Information(" - Tenant: {Tenant:l}", nameOfDeploymentTenant);
            }

            if (channel != null)
            {
                commandOutputProvider.Information(" - Channel: {Channel:l}", channel.Name);
            }

            commandOutputProvider.Information("   Date: {$Date:l}", dashboardItem.QueueTime);
            commandOutputProvider.Information("   Duration: {Duration:l}", dashboardItem.Duration);

            if (dashboardItem.State == TaskState.Failed)
            {
                commandOutputProvider.Error("   State: {$State:l}", dashboardItem.State);
            }
            else
            {
                commandOutputProvider.Information("   State: {$State:l}", dashboardItem.State);
            }

            commandOutputProvider.Information("   Version: {Version:l}", release.Version);
            commandOutputProvider.Information("   Assembled: {$Assembled:l}", release.Assembled);
            commandOutputProvider.Information("   Package Versions: {PackageVersion:l}", GetPackageVersionsAsString(release.SelectedPackages));
            commandOutputProvider.Information("   Release Notes: {ReleaseNotes:l}", GetReleaseNotes(release));
            commandOutputProvider.Information(string.Empty);
        }
        private void before_each()
        {
            var environment      = A.Fake <ISnapshotEnvironment>(x => x.Strict());
            var repository       = A.Fake <IOctopusRepository>(x => x.Strict());
            var componentBuilder = A.Fake <IBuildSnapshotComponents>(x => x.Strict());

            _builder = new SnapshotComponentVersionBuilder(environment, repository, componentBuilder);

            var environmentId = "Env01";
            var projectId     = "Proj01";

            _releaseId      = "Release01";
            _releaseVersion = "ReleaseVersion01";

            A.CallTo(() => environment.Id).Returns(environmentId);

            _expectedComponent = new SnapshotComponent(projectId, "project name", "project group name");
            var components = new List <SnapshotComponent> {
                _expectedComponent
            };

            A.CallTo(() => componentBuilder.Build()).Returns(components);

            _itemResource = new DashboardItemResource
            {
                EnvironmentId  = environmentId,
                ProjectId      = projectId,
                ReleaseId      = _releaseId,
                ReleaseVersion = _releaseVersion
            };
            var dashboardResource = new DashboardResource
            {
                Items = new List <DashboardItemResource> {
                    _itemResource
                }
            };
            var dashboardRepository = A.Fake <IDashboardRepository>(x => x.Strict());

            A.CallTo(() => dashboardRepository.GetDashboard()).Returns(dashboardResource);
            A.CallTo(() => repository.Dashboards).Returns(dashboardRepository);
        }
示例#7
0
        public async Task LogDeploymentInfo(DashboardItemResource dashboardItem, IDictionary <string, string> environmentsById, IDictionary <string, string> projectedById, IDictionary <string, string> tenantsById)
        {
            var nameOfDeploymentEnvironment = environmentsById[dashboardItem.EnvironmentId];
            var nameOfDeploymentProject     = projectedById[dashboardItem.ProjectId];
            var release = await Repository.Releases.Get(dashboardItem.ReleaseId).ConfigureAwait(false);

            Log.Information(" - Project: {Project:l}", nameOfDeploymentProject);
            Log.Information(" - Environment: {Environment:l}", nameOfDeploymentEnvironment);
            if (!string.IsNullOrEmpty(dashboardItem.TenantId))
            {
                var nameOfDeploymentTenant = tenantsById[dashboardItem.TenantId];
                Log.Information(" - Tenant: {Tenant:l}", nameOfDeploymentTenant);
            }

            if (!string.IsNullOrEmpty(dashboardItem.ChannelId))
            {
                var channel = await Repository.Channels.Get(dashboardItem.ChannelId).ConfigureAwait(false);

                Log.Information(" - Channel: {Channel:l}", channel.Name);
            }

            Log.Information("   Date: {$Date:l}", dashboardItem.QueueTime);
            Log.Information("   Duration: {Duration:l}", dashboardItem.Duration);

            if (dashboardItem.State == TaskState.Failed)
            {
                Log.Error("   State: {$State:l}", dashboardItem.State);
            }
            else
            {
                Log.Information("   State: {$State:l}", dashboardItem.State);
            }

            Log.Information("   Version: {Version:l}", release.Version);
            Log.Information("   Assembled: {$Assembled:l}", release.Assembled);
            Log.Information("   Package Versions: {PackageVersion:l}", GetPackageVersionsAsString(release.SelectedPackages));
            Log.Information("   Release Notes: {ReleaseNotes:l}", release.ReleaseNotes != null ? release.ReleaseNotes.Replace(Environment.NewLine, @"\n") : "");

            Log.Information("");
        }
        private static void LogDeploymentInfo(ILogger log, DashboardItemResource dashboardItem, ReleaseResource release, ChannelResource channel,
                                              IDictionary <string, string> environmentsById, IDictionary <string, string> projectedById, IDictionary <string, string> tenantsById)
        {
            var nameOfDeploymentEnvironment = environmentsById[dashboardItem.EnvironmentId];
            var nameOfDeploymentProject     = projectedById[dashboardItem.ProjectId];

            log.Information(" - Project: {Project:l}", nameOfDeploymentProject);
            log.Information(" - Environment: {Environment:l}", nameOfDeploymentEnvironment);
            if (!string.IsNullOrEmpty(dashboardItem.TenantId))
            {
                var nameOfDeploymentTenant = tenantsById[dashboardItem.TenantId];
                log.Information(" - Tenant: {Tenant:l}", nameOfDeploymentTenant);
            }

            if (channel != null)
            {
                log.Information(" - Channel: {Channel:l}", channel.Name);
            }

            log.Information("   Date: {$Date:l}", dashboardItem.QueueTime);
            log.Information("   Duration: {Duration:l}", dashboardItem.Duration);

            if (dashboardItem.State == TaskState.Failed)
            {
                log.Error("   State: {$State:l}", dashboardItem.State);
            }
            else
            {
                log.Information("   State: {$State:l}", dashboardItem.State);
            }

            log.Information("   Version: {Version:l}", release.Version);
            log.Information("   Assembled: {$Assembled:l}", release.Assembled);
            log.Information("   Package Versions: {PackageVersion:l}", GetPackageVersionsAsString(release.SelectedPackages));
            log.Information("   Release Notes: {ReleaseNotes:l}", release.ReleaseNotes != null ? release.ReleaseNotes.Replace(Environment.NewLine, @"\n") : "");

            log.Information("");
        }
示例#9
0
 public static DeploymentTask ToDeploymentTask(this DashboardItemResource dashboardItemResource, string projectName, string environmentName)
 {
     return(new DeploymentTask()
     {
         TaskResource = new TaskResource()
         {
             Id = dashboardItemResource.TaskId,
             QueueTime = dashboardItemResource.QueueTime,
             CompletedTime = dashboardItemResource.CompletedTime,
             State = dashboardItemResource.State,
             HasPendingInterruptions = dashboardItemResource.HasPendingInterruptions,
             HasWarningsOrErrors = dashboardItemResource.HasWarningsOrErrors,
             ErrorMessage = dashboardItemResource.ErrorMessage,
             Duration = dashboardItemResource.Duration,
         },
         ProjectId = dashboardItemResource.Id,
         ProjectName = projectName,
         EnvironmentId = dashboardItemResource.EnvironmentId,
         EnvironmentName = environmentName,
         ReleaseId = dashboardItemResource.ReleaseId,
         DeploymentId = dashboardItemResource.DeploymentId,
         ReleaseVersion = dashboardItemResource.ReleaseVersion,
     });
 }