The problem:
I have configure a "Slack Notifier" service in Google Cloud Run, following this guide: https://cloud.google.com/build/docs/configuring-notifications/configure-slack
Every thing is working pretty well, builds are triggered automatically and I do get my Slack notifications as configured. But the problem is that the notification popup in Slack (Windows Desktop client app) says "no preview available" and I can't figure out how to make that part work.
I've been "Googling" this for hours to no avail, so now I'm reaching out here in the hope that someone knows how to resolve this.
So far all I've found is that "no preview available" will show if the message has no text content, but mine has text, here's a preview of the full message content:
Further details:
Here is my Slack Notifier configuration yaml:
apiVersion: cloud-build-notifiers/v1
kind: SlackNotifier
metadata:
name: example-slack-notifier
spec:
notification:
filter: build.status in [Build.Status.SUCCESS, Build.Status.FAILURE, Build.Status.TIMEOUT]
params:
buildStatus: $(build.status)
delivery:
webhookUrl:
secretRef: webhook-url
template:
type: golang
uri: gs://path-to-json-template.json
secrets:
- name: webhook-url
value: projects/.../versions/latest
And here is the JSON template:
[
{
"type": "section",
"text": {
"type": "plain_text",
"text": "Cloud Build Completed"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*BUILD DETAILS:*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Status: {{.Params.buildStatus}}\nEnvironment: {{.Build.Substitutions._ENVIRONMENT}}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*GITHUB DETAILS:*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Repo: {{.Build.Substitutions.REPO_NAME}}\nBranch: {{.Build.Substitutions.BRANCH_NAME}}\nPR: #{{.Build.Substitutions._PR_NUMBER}}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "You can access your service here: {{.Build.Substitutions._DEV_SERVICE_URL}}"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "View Build Logs"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Logs"
},
"value": "click_me_123",
"url": "{{.Build.LogUrl}}",
"action_id": "button-action"
}
}
]
If anyone can help me figure out how to replace "no preview available" with something meaningful like "Cloud Build Completed!" that would be greatly appreciated.