Пример #1
0
        public IDisposable CreateTemporaryDeployment(string statusText, out ChangeSet tempChangeSet, ChangeSet changeSet = null, string deployedBy = null)
        {
            var tracer = _traceFactory.GetTracer();

            using (tracer.Step("Creating temporary deployment"))
            {
                changeSet = changeSet != null && changeSet.IsTemporary ? changeSet : CreateTemporaryChangeSet();
                IDeploymentStatusFile statusFile = _status.Create(changeSet.Id);
                statusFile.Id          = changeSet.Id;
                statusFile.Message     = changeSet.Message;
                statusFile.Author      = changeSet.AuthorName;
                statusFile.Deployer    = deployedBy;
                statusFile.AuthorEmail = changeSet.AuthorEmail;
                statusFile.Status      = DeployStatus.Pending;
                statusFile.StatusText  = statusText;
                statusFile.IsTemporary = changeSet.IsTemporary;
                statusFile.IsReadOnly  = changeSet.IsReadOnly;
                statusFile.Save();
            }

            tempChangeSet = changeSet;

            // Return a handle that deletes the deployment on dispose.
            return(new DisposableAction(() =>
            {
                if (changeSet.IsTemporary)
                {
                    _status.Delete(changeSet.Id);
                }
            }));
        }
Пример #2
0
        public void CreateDeployment(DeployResult deployResult, string details)
        {
            var    id   = deployResult.Id;
            string path = Path.Combine(_environment.DeploymentsPath, id);
            IDeploymentStatusFile statusFile = _status.Open(id);

            if (statusFile != null)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.Conflict, String.Format("Deployment with id '{0}' exists", id)));
            }

            FileSystemHelpers.EnsureDirectory(path);
            statusFile             = _status.Create(id);
            statusFile.Status      = deployResult.Status;
            statusFile.Message     = deployResult.Message;
            statusFile.Deployer    = deployResult.Deployer;
            statusFile.Author      = deployResult.Author;
            statusFile.AuthorEmail = deployResult.AuthorEmail;
            statusFile.StartTime   = deployResult.StartTime;
            statusFile.EndTime     = deployResult.EndTime;

            // miscellaneous
            statusFile.Complete     = true;
            statusFile.IsReadOnly   = true;
            statusFile.IsTemporary  = false;
            statusFile.ReceivedTime = deployResult.StartTime;
            // keep it simple regardless of success or failure
            statusFile.LastSuccessEndTime = deployResult.EndTime;
            statusFile.Save();

            if (deployResult.Current)
            {
                _status.ActiveDeploymentId = id;
            }

            var     logger = new StructuredTextLogger(Path.Combine(path, DeploymentManager.TextLogFile), _analytics);
            ILogger innerLogger;

            if (deployResult.Status == DeployStatus.Success)
            {
                innerLogger = logger.Log("Deployment successful.");
            }
            else
            {
                innerLogger = logger.Log("Deployment failed.", LogEntryType.Error);
            }

            if (!String.IsNullOrEmpty(details))
            {
                innerLogger.Log(details);
            }
        }