public NancyPipelineRoutes(IPipeline pipeline, INotificationTarget notifier) { Post["/bitbucket"] = parameters => { string notificationString = Request.Form.Payload; var commitNotification = JsonConvert.DeserializeObject<BitbucketPostReceiveNotification>(notificationString); commitNotification.Commits.ForEach(c => pipeline.AddToPipeline(new Commit(c.Author, c.Message, c.Branch))); return "THANKS BITBUCKET"; }; Post["/jenkins"] = parameters => { var buildNotification = this.Bind<JenkinsBuildNotification>(); var buildStep = pipeline[buildNotification.Name]; if (buildNotification.Build.Phase == "STARTED") { buildStep.Start(); } else if (buildNotification.Build.Phase == "FINISHED") { if (buildNotification.Build.Status == "SUCCESS") { buildStep.Pass(); } else { buildStep.Fail(); } } return "THANKS FOR THE BUILD DEETS"; }; }
public static void AddReceiver(INotificationTarget target, string message) { if (target == null) { return; } Receivers.Add(new KeyValuePair <string, INotificationTarget>(message, target)); if (EqualsMessage(message, "DocumentChanged") && CurrentDocument != null) { target.OnNotificationReceived(null, "DocumentChanged", CurrentDocument); } }
public WebhookController(Settings settings, INotificationTarget notificationTarget, IHashVerify hashVerify, IMessageQueue messageQueue, ILogger <WebhookController> logger) { _settings = settings; _notificationTarget = notificationTarget; _hashVerify = hashVerify; _messageQueue = messageQueue; _logger = logger; }
public static void RemoveReceiver(INotificationTarget target, string message) { int i = 0; while (i < Receivers.Count) { if (message == null || Receivers[i].Key == message) { if (target == null || Receivers[i].Value == target) { Receivers.RemoveAt(i); i--; } } i++; } }
public Pipeline(INotificationTarget notifier, params IBuildStep[] steps) { this._notifier = notifier; this._steps = steps.Zip(Enumerable.Range(0, steps.Length), (step, i) => { var nextStep = steps.ElementAtOrDefault(i + 1); if (nextStep == null) { step.SuccessCallback = RecordSuccessfulCommits; } else { step.SuccessCallback = nextStep.AddWaitingCommits; } step.FailureCallback = (commits => PipelineFailed(step, commits)); return step; }).ToList(); }
public NancyDebugRoutes(INotificationTarget notifier) { Get["/send-test-message"] = parameters => { notifier.SendNotification("Tim", "Test Message"); return "HELLO"; }; Post["/debug"] = parameters => { var body = new StreamReader(Request.Body).ReadToEnd(); notifier.SendNotification("Debug: Body", !String.IsNullOrEmpty(body) ? body : "No body"); string form = String.Join(",", Request.Form.Keys); notifier.SendNotification("Debug: Form", !String.IsNullOrEmpty(form) ? form : "No form"); string query = String.Join(",", Request.Query.Keys); notifier.SendNotification("Debug: Query", !String.IsNullOrEmpty(query) ? query : "No query"); string parametersString = String.Join(",", parameters.Keys); notifier.SendNotification("Debug: Parameters", !String.IsNullOrEmpty(parametersString) ? parametersString : "No params"); return "DEBUGGED"; }; this.OnError += (ctx, ex) => { while (ex is AggregateException) { ex = ex.InnerException; } var message = ex.Message + " at " + ex.StackTrace; notifier.SendNotification("OnError", message); return "Error!"; }; }