Open connelld-willa opened 2 years ago
UPDATE:
I redeployed with the previous version us-east1-docker.pkg.dev/gcb-release/cloud-build-notifiers/slack@sha256:357053acf6426028241d140c54f97581d9aa9cf70ffd6a92b0a71d2e7013f4b9
And it works fine. So my guess still, is there is something up with the latest version.
Seems like this is the commit: https://github.com/GoogleCloudPlatform/cloud-build-notifiers/commit/b0668daa20c1f653e240545f8a289f12b027fab1
In which case, I'm wondering if one of the variables being passed to the template is has embedded quotes that need to be escaped. I'm looking at my cloud build pub/sub messages and I don't see an obvious problem, however. My best, crazy guess is that it has something to do with some unicode encoded equal sign in the "logUrl" variable.
The template looks for "projectId", "id", "status", and "logUrl". The first three are just plain ol' ASCII, no special characters, no quotes, etc. The fourth, logUrl, is https://console.cloud.google.com/cloud-build/builds/19f99583-3263-48f5-968f-a7e101823d42?project\u003d12345678
. I'm thinking maybe it's that \u003d
.
@dpkirchner I agree that it's the commit you reference, but I don't think it's an issue with the template values. That commit wires the slack notifier up to use a golang template which gets populated over in notifiers.go.
I copied the new file slack.json
into the cloud storage bucket where I have my slack notifier yaml configs, and added a template config to them:
apiVersion: cloud-build-notifiers/v1
kind: SlackNotifier
metadata:
name: notifier-name
spec:
notification:
filter: build.status == Build.Status.SUCCESS
delivery:
webhookUrl:
secretRef: webhook-url
template:
type: golang
uri: gs://bucket-name/slack.json
That cleared the errors in the logs, although the notification is not the prettiest. I guess now I can customize it though.
Seems like the documentation needs to be updated to reflect that a template for slack attachment blocks needs to be configured.
Another workaround for folks using the slack notifier with the setup.sh
shell script. I'm sure this will break the other notifiers though so don't utilize this if you mix them.
@@ -123,7 +123,7 @@ main() {
DESTINATION_CONFIG_PATH="${DESTINATION_BUCKET_URI}/${SOURCE_CONFIG_BASENAME}"
SOURCE_TEMPLATE_BASENAME=$(basename "${SOURCE_TEMPLATE_PATH}")
DESTINATION_TEMPLATE_PATH="${DESTINATION_BUCKET_URI}/${SOURCE_TEMPLATE_BASENAME}"
- IMAGE_PATH="us-east1-docker.pkg.dev/gcb-release/cloud-build-notifiers/${NOTIFIER_TYPE}:latest"
+ IMAGE_PATH="us-east1-docker.pkg.dev/gcb-release/cloud-build-notifiers/${NOTIFIER_TYPE}:slack-1.14.0"
SERVICE_NAME="${NOTIFIER_TYPE}-notifier"
SUBSCRIPTION_NAME="${NOTIFIER_TYPE}-subscription"
INVOKER_SA="cloud-run-pubsub-invoker@${PROJECT_ID}.iam.gserviceaccount.com"
@dandebiase FYI, using this workaround throws the error below when I run the setup.sh script.
Deployment failed
ERROR: (gcloud.run.deploy) The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.
For those who face this error unmarsal JSON my case was I accidentally had comments in yaml config & json file like
secretRef: webhook-url
template:
type: golang
uri: gs://xxxx/slack-msg2.json # some comment here
I have been following these instructions on the GCP documentation page. I have done nothing custom beyond substituting variables.
However, it is not working and I see tons of error messages in the cloud run logs saying:
There is a somewhat similar closed issue here - and the solution was to pin an older version. If thats the case, what version should it be?
Also, how would I set the retry limit invocations to the cloud run service from pubsub? I think would have racked up quite the bill if I had not been looking.