-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slack custom message #91
base: master
Are you sure you want to change the base?
Conversation
What are the chances this gets merged/we get something like this? Would like a way to configure the slack notifications with trigger name or repository included in the slack notifications at the minimum. Is the recommended way to create an image based off this PR for now? |
If you're using an image based off this PR, here's a template where you can get a message out of the build via the build env: textTemplate: 'Here is my custom message: {{if .Options}}{{range .Options.Env}}{{if ge (len .) 10}}{{if eq (slice . 0 10) "SLACK_MSG="}}{{slice . 10}}{{end}}{{end}}{{else}}default if SLACK_MSG env not found{{end}}{{else}}default if no options{{end}}' where the env var is called options:
env:
- SLACK_MSG=print me to slack and you will see:
If you rename the env var, remember to replace the use of Thanks @bouk for this =) @NotNoah The Cloud Build team are working on a requirements doc to do this in their own way because they "want to have a standardized implementation for all notifiers": see #95 and #90 (comment) So I'm looking forward to when we can do this without having to build our own image based on this PR =) |
Trying to get some movement on this one. I published a proposed message format here: #95 (comment). My format is not a serious proposal other than to get the Cloud Build Team moving on the requirements piece of this. I reckon those of you who worked on this PR and are actively using an image based on it would have better input on what the message format should be. |
Is there a way to get the trigger name, or other stuff through this PR? Or does it require additional changes? I'd be happy to use this PR to setup my custom triggers, even before merging, but I'm not sure how to do it. Thanks! |
Here I'm adding support for defining a custom template to the Slack notifier. Pretty straightforward, just using text/template with a default template that's the same as what the Sprintf does right now.
I also made a small fix to pass down the context when submitting the webhook, just saw that this was not being done before.
Closes #90