public string ParseTemplateText(string template, BaseProcess process, Func<string, string> valueEncoder = null) { return ParseTemplateTextKeywords(template, new Dictionary<string, Func<string>>() { {"instanceName", () => process.InstanceName}, {"result", () => process.Skipped ? "skipped" : (process.Succeeded ? "OK" : "failed")}, {"tags", () => string.Join(",", process.Instance.Tags)}, {"log", () => process.FullLog }, {"changeLog", () => string.Join(Environment.NewLine, process.Instance.ChangeLog)}, {"changeLogShort", () => string.Join(Environment.NewLine, process.Instance.ChangeLogShort)}, {"treeish", () => process.Instance.Treeish}, {"machineName", () => Environment.MachineName}, }); }
public void Notify(BaseProcess process) { try { if (!ShouldNotify(process)) { return; } process.Log(string.Format("Notifying using {0}:{1}", this.GetType().Name, Key)); DoNotify(process); process.Log("Notified"); } catch (Exception ex) { process.Log(string.Format("Error executing {0}: {1}", this.GetType().Name, ex.Message)); } }
protected virtual bool ShouldNotify(BaseProcess process) { if (!(process is Deployment)) { return false; } if (((Deployment) process).Dry) { return false; } if (process.Skipped && Settings.ContainsKey("IgnoreSkipped") && Settings["IgnoreSkipped"].ToLowerInvariant() == "true") { return false; } if (process.Succeeded && Settings.ContainsKey("IgnoreSucceeded") && Settings["IgnoreSucceeded"].ToLowerInvariant() == "true") { return false; } if (!process.Succeeded && Settings.ContainsKey("IgnoreFailed") && Settings["IgnoreFailed"].ToLowerInvariant() == "true") { return false; } return true; }
internal static void Log(string message, Instance instance, BaseProcess process) { TraceSource.TraceInformation(message); }
protected abstract void DoNotify(BaseProcess process);
internal void Log(string message, BaseProcess process) { Hub.Log(message, this, process); }