Comments (19)
As @wyardley mentioned, we were able to get this working with the changes from PR #139. This is our template file. Make sure to change {orgName}
to your org name. We just have it static inside the JSON. You want this JSON file to return an array of blocks to send to Slack. The color bar attachment gets handled from within the Go code.
[
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Status:* {{.Build.Status}}\n*Repo:* <https://github.com/{orgName}/{{.Build.Substitutions.REPO_NAME}}|{{.Build.Substitutions.REPO_NAME}}>\n*Commit:* <https://github.com/{orgName}/{{.Build.Substitutions.REPO_NAME}}/commit/{{.Build.Substitutions.COMMIT_SHA}}|{{.Build.Substitutions.SHORT_SHA}}>"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "View Job"
},
"value": "click_me_123",
"url": "{{.Build.LogUrl}}",
"action_id": "button-action"
}
}
]
Example configuration:
spec:
notification:
template:
type: golang
uri: gs://my-bucket/my-slack-template.json
from cloud-build-notifiers.
Hi all, we on the Cloud Build team are definitely aware of this FR and are working on short-term and long-term plans! Please stay tuned...
from cloud-build-notifiers.
Hi all, we on the Cloud Build team are definitely aware of this FR and are working on short-term and long-term plans! Please stay tuned...
@LOZORD Hi, I've been waiting for this feature for quite some time, any progress?
from cloud-build-notifiers.
If the GCP version of this will not be available soon, I propose just merging #91. It's a simple enough PR that it probably wouldn't be difficult for the GCP team to make their implementation compatible or at least make it fail gracefully if the implementation changes.
from cloud-build-notifiers.
The updates have now also been published / built. Thinking maybe this request can be closed now?
from cloud-build-notifiers.
Hi (Not) Noah,
We are working on a public requirements doc for templating and bindings in #95 . If there's anything that you'd like beyond what's suggested there, please feel free to comment. I can't comment on the timeline of this yet.
Thanks,
Leo
from cloud-build-notifiers.
It seems that the request is indeed fulfilled.
However, the latest code changes are not yet deployed, as you can see here the last image was uploaded in March.
However, you can checkout the latest code and build your own image and push that in your repository or whatever.
From the code, the configuration looks like it should be this:
apiVersion: cloud-build-notifiers/v1
kind: SlackNotifier
metadata:
name: cloud-build-slack-notifier
spec:
notification:
template:
type: golang
uri: gs://foo/bar
filter: ...
delivery:
webhookUrl:
secretRef: webhook-url
secrets:
- name: webhook-url
value: ....
The template.type
is required and the only allowed value is golang
.
The template.uri
is the object uri.
There is also the template.content
which takes raw template.
from cloud-build-notifiers.
gs://bucketname/message-template.json
from cloud-build-notifiers.
I vouch for this feature! It would be very useful because the message that are displayed now are very generic.
from cloud-build-notifiers.
I agree. Having more details will be useful in slack notifications. We have multiple triggers and today in slack we don't know which one triggered the build.
from cloud-build-notifiers.
hi @LOZORD so maybe I should close the #63?
from cloud-build-notifiers.
Sure, but I really do appreciate for your contribution 😄 Would using Golang templates satisfy your use case? Do you have any preference between that templating language and Mustache for example? We are considering a few different options for templating.
from cloud-build-notifiers.
Personally I don't have preference as the goal is pretty simple. The PR used go templates because it was convenient and in stdlib ;)
from cloud-build-notifiers.
Any updates on something like this?
from cloud-build-notifiers.
Hi (Not) Noah,
We are working on a public requirements doc for templating and bindings in #95 . If there's anything that you'd like beyond what's suggested there, please feel free to comment. I can't comment on the timeline of this yet.
Thanks,
Leo
Thanks for the update! 😃 this will be very useful once released!
from cloud-build-notifiers.
Hi @jfragoulis ,
Could you let me know the example value for template.uri
?
from cloud-build-notifiers.
However, you can checkout the latest code and build your own image and push that in your repository or whatever.
Building an updated image solved my problem. Thank you for pointing it out.
from cloud-build-notifiers.
Not sure if it's because I asked on Slack or another reason, but got built today:
https://console.cloud.google.com/artifacts/docker/gcb-release/us-east1/cloud-build-notifiers/slack/sha256:3f94609560920a327fefd1f153560ec21c8dfa0f97916305c144518348e73e20
from cloud-build-notifiers.
Even though it got built today, the Slack color issue mentioned in #139 and #137 caused it to not work 100%.
@jfragoulis: we were able to use our own build of a fork of the upstream repo along with your changes from #139, and it works perfectly; it would be great to see this fix incorporated and built so that we don't have to, so hopefully someone from the team that manages this project will review it soon.
I'll let @deriegle comment with an example of a working template, as there were some bits of getting it to work that were a little non-obvious.
Other question: is source:
an empty data structure in the pub/sub message because we're using GH? we seem to have to use the substitutions instead to get the repo name.
from cloud-build-notifiers.
Related Issues (20)
- allow optional configuration of log levels HOT 1
- [SLACK NOTIFIER] Region not contained in the url HOT 3
- [HTTP Notifications] Empty Body HOT 1
- Not able to use GCP Cloud Build Trigger Name in Email Subject or Body HOT 3
- {{.Build.FailureInfo.Detail}} doesn't work. HOT 1
- [SLACK] color side bar is not working in notification messages HOT 1
- Surfacing author / username information to Slack notifier (GH) HOT 2
- New line in a substitution fails Slack notification HOT 6
- Template vars passed to slack.json (Block Kit template) should escape or replace double quotation marks (ie. {{.Build.FailureInfo.Detail}}) HOT 1
- The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable HOT 6
- [Request] Allow using secret value for HTTP Notifier webhook
- should extract build id in another way when build status is unknown HOT 1
- Go Template `replace` function not found HOT 1
- SlackNotifier message notification popup says "no preview available" in Slack desktop client for Windows HOT 2
- SlackNotifier Error "field template not found in type notifiers.Notification" HOT 2
- Slack notifier fails to deploy because it doesn't listen to port 8080 HOT 7
- [REQUEST] Support for Bitbucket Commit Statuses HOT 1
- Slack notification: {{.Params.buildStatus}} substitution not working HOT 5
- githubissues notifier - use single notifier for multiple repositories HOT 4
- what is the upgrade path for slack notifier versions < 0.15.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloud-build-notifiers.