diff --git a/README.md b/README.md index 4a06daad..abdcd2f1 100644 --- a/README.md +++ b/README.md @@ -1143,6 +1143,40 @@ Now, replace `echo` with any command you like, and rewrite `args` that actually - linting - testing +Hooks expose additional template expressions: + +`.Event.Name` is the name of the hook event. + +`.Event.Error` is the error generated by a failed release, exposed for `posysync` hooks only when a release fails, otherwise its value is `nil`. + +You can use the hooks event expressions to send notifications to platforms such as `Slack`, `MS Teams`, etc. + +The following example passes arguments to a script which sends a notification: + +```yaml +releases: +- name: myapp + chart: mychart + # *snip* + hooks: + - events: + - presync + - postsync + showlogs: true + command: notify.sh + args: + - --event + - '{{`{{ .Event.Name }}`}}' + - --status + - '{{`{{ if .Event.Error }}failure{{ else }}success{{ end }}`}}' + - --environment + - '{{`{{ .Environment.Name }}`}}' + - --namespace + - '{{`{{ .Release.Namespace }}`}}' + - --release + - '{{`{{ .Release.Name }}`}}' +``` + For templating, imagine that you created a hook that generates a helm chart on-the-fly by running an external tool like ksonnet, kustomize, or your own template engine. It will allow you to write your helm releases with any language you like, while still leveraging goodies provided by helm.