public Deployer(string configurationFile = "config.xml") { if (!Directory.Exists("logs")) { Directory.CreateDirectory("logs"); } Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.ColoredConsole() .WriteTo.RollingFile(@"logs\zebra-deploy-{Date}.log") .CreateLogger(); _log = Log.ForContext <Deployer>(); // Recreate this so we can log properly _configuration = ZebraConfiguration.LoadFromFile(configurationFile); _watcher = new DebouncingFileSystemWatcher(_configuration.BasePath, "*.zip", true); _threads = new Dictionary <string, Thread>(); _watcher.FileChanged += WatcherFileChanged; _stripes = _configuration.Stripes.Select(c => new Stripe(c)).ToList(); _globalReporters = _configuration.Reporters.Select(StripeReporter.CreateStep).Where(x => x != null).ToList(); var nancyPort = 7777; try { var bootstrapper = new ZebraBootstrapper(_configuration, _stripes); _host = new NancyHost(new Uri("http://localhost:" + nancyPort), bootstrapper, new HostConfiguration { RewriteLocalhost = true }); } catch (HttpListenerException) { _log.Warning("Failed to start NancyHost for port {port}.", nancyPort); } }
public void CleanStepHasExcludes() { var config = ZebraConfiguration.Load(Resources.SampleConfiguration); var stripe = config.Stripes.First(); var cleanStep = stripe.Steps.Where(step => step.GetType() == typeof (CleanStepConfiguration)).Cast<CleanStepConfiguration>().First(); Assert.AreEqual(1, cleanStep.Excludes.Count); Assert.AreEqual("images", cleanStep.Excludes.First()); }
public void LoadSampleConfigurationWithGlobalReporters() { var config = ZebraConfiguration.Load(Resources.SampleConfigurationWithReporters); Assert.IsNotNull(config); Assert.AreEqual(1, config.Reporters.Count); Assert.AreEqual(1, config.Reporters.Count(step => step.GetType() == typeof(HipChatReporterConfiguration))); Assert.IsFalse(config.Reporters.First().ReportSuccess); Assert.IsFalse(config.Reporters.First().ReportFailure); }
public void LoadSampleConfiguration() { var config = ZebraConfiguration.Load(Resources.SampleConfiguration); Assert.IsNotNull(config); Assert.AreEqual(@"D:\zebra-deploy\", config.BasePath); Assert.AreEqual(1, config.Stripes.Count); var stripe = config.Stripes.First(); Assert.AreEqual("website.zip", stripe.File); Assert.AreEqual(1, stripe.Steps.Count(step => step.GetType() == typeof(CleanStepConfiguration))); Assert.AreEqual(1, stripe.Steps.Count(step => step.GetType() == typeof(OutputStepConfiguration))); Assert.AreEqual(2, stripe.Steps.Count(step => step.GetType() == typeof(AppPoolStepConfiguration))); Assert.AreEqual(2, stripe.Steps.Count(step => step.GetType() == typeof(WebsiteStepConfiguration))); Assert.AreEqual(2, stripe.Steps.Count(step => step.GetType() == typeof(ServiceStepConfiguration))); }
public ZebraModule(ZebraConfiguration configuration, IList <Stripe> stripes) : base("/") { Get["/"] = _ => { var model = stripes.Select(s => new StripeModel { File = s.File, CurrentStep = s.CurrentStep ?? "Waiting", LastDeploy = s.LastDeploy, Progress = s.Progress, Failed = s.Failed }).ToArray(); return(Negotiate .WithModel(model) .WithView("Index")); }; Post["/"] = _ => { if (!configuration.AllowHttpUploads) { return(Negotiate.WithStatusCode(HttpStatusCode.MethodNotAllowed)); } using (var rijAlg = new RijndaelManaged()) { rijAlg.Key = Convert.FromBase64String(configuration.SecurityKey); rijAlg.IV = Convert.FromBase64String(configuration.SecurityIV); var decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV); using (var csDecrypt = new CryptoStream(Request.Body, decryptor, CryptoStreamMode.Read)) { using (var target = File.OpenWrite("")) { csDecrypt.CopyTo(target); } } } return(Negotiate .WithStatusCode(HttpStatusCode.NoContent)); }; }
public ZebraBootstrapper(ZebraConfiguration configuration, List <Stripe> stripes) { _configuration = configuration; _stripes = stripes; }