Beispiel #1
0
        private bool IsLatestPendingDeployment(ref string id, out DeployResult pending)
        {
            if (String.Equals(Constants.LatestDeployment, id))
            {
                using (_tracer.Step("DeploymentService.GetLatestDeployment"))
                {
                    var results = _deploymentManager.GetResults();
                    pending = results.Where(r => r.Status != DeployStatus.Success && r.Status != DeployStatus.Failed).FirstOrDefault();
                    if (pending != null)
                    {
                        _tracer.Trace("Deployment {0} is {1}", pending.Id, pending.Status);
                        return(true);
                    }

                    var latest = results.Where(r => r.EndTime != null).OrderBy(r => r.EndTime.Value).LastOrDefault();
                    if (latest != null)
                    {
                        _tracer.Trace("Deployment {0} is {1} at {2}", latest.Id, latest.Status, latest.EndTime.Value.ToString("o"));

                        id = latest.Id;
                    }
                    else
                    {
                        _tracer.Trace("Could not find latest deployment!");
                    }
                }
            }

            pending = null;
            return(false);
        }
Beispiel #2
0
        public HttpResponseMessage GetDeploymentScript()
        {
            using (_tracer.Step("DeploymentService.GetDeploymentScript"))
            {
                if (!_deploymentManager.GetResults().Any())
                {
                    throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Need to deploy website to get deployment script."));
                }

                string deploymentScriptContent = _deploymentManager.GetDeploymentScriptContent();

                if (deploymentScriptContent == null)
                {
                    throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Operation only supported if not using a custom deployment script"));
                }

                HttpResponseMessage response = Request.CreateResponse();
                response.Content = ZipStreamContent.Create("deploymentscript.zip", _tracer, zip =>
                {
                    // Add deploy.cmd to zip file
                    zip.AddFile(DeploymentManager.DeploymentScriptFileName, deploymentScriptContent);

                    // Add .deployment to cmd file
                    zip.AddFile(DeploymentSettingsProvider.DeployConfigFile, "[config]\ncommand = {0}\n".FormatInvariant(DeploymentManager.DeploymentScriptFileName));
                });

                return(response);
            }
        }
Beispiel #3
0
 private IEnumerable <DeployResult> GetResults(HttpRequestMessage request)
 {
     foreach (var result in _deploymentManager.GetResults())
     {
         result.Url    = UriHelper.MakeRelative(request.RequestUri, result.Id);
         result.LogUrl = UriHelper.MakeRelative(request.RequestUri, result.Id + "/log");
         yield return(result);
     }
 }
Beispiel #4
0
 public ActionResult GetResults()
 {
     return(Json(_deploymentManager.GetResults(), JsonRequestBehavior.AllowGet));
 }