Skip to content
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

SlackNotifier Error "field template not found in type notifiers.Notification" #181

Open
TeChn4K opened this issue Sep 14, 2023 · 2 comments

Comments

@TeChn4K
Copy link

TeChn4K commented Sep 14, 2023

Hi guys,

I'm getting this error on deployment :

Container called exit(255).
/go-src/slack/main.go:33 +0x7b
...
line 10: field template not found in type notifiers.Notification
...
main.go: fatal error: failed to get config from GCS: failed to parse configuration from YAML at "xxx/slack/cloud-build/conf.yaml": yaml: unmarshal errors:

My config file seems reachable. When I specify a not existing config path, it throws a different error.

Any idea?

conf.yaml

apiVersion: cloud-build-notifiers/v1
kind: SlackNotifier
metadata:
  name: cloud-build-slack-notifier
spec:
  notification:
    delivery:
      webhookUrl:
        secretRef: webhook-url
    template:
      type: golang
      uri: gs://xxx/slack/cloud-build/message.json

  secrets:
    - name: webhook-url
      value: projects/xxx/secrets/xxx/versions/latest

message.json

[
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "Cloud Build {{.Build.ProjectId}} {{.Build.Id}} {{.Params.buildStatus}}"
      }
    },
    {
      "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"
      }
    }
  ]
 gcloud run deploy slack-notify-cloud-build \
   --image=us-east1-docker.pkg.dev/gcb-release/cloud-build-notifiers/slack:slack-1.14.0 \
   --no-allow-unauthenticated \
   --update-env-vars=CONFIG_PATH=gs://xxx/slack/cloud-build/conf.yaml,PROJECT_ID=xxx
@TeChn4K
Copy link
Author

TeChn4K commented Sep 14, 2023

When I update the conf.yaml to add params and filter, I get a new error ...

line 13: field template not found in type notifiers.Notification
line 8: field params not found in type notifiers.Notification
...
main.go: fatal error: failed to get config from GCS: failed to parse configuration from YAML at "xxx/slack/cloud-build/conf.yaml": yaml: unmarshal errors:


conf.yaml

apiVersion: cloud-build-notifiers/v1
kind: SlackNotifier
metadata:
  name: cloud-build-slack-notifier
spec:
  notification:
    filter: build.status == Build.Status.SUCCESS
    params:
      buildStatus: $(build.status)
    delivery:
      webhookUrl:
        secretRef: webhook-url
    template:
      type: golang
      uri: gs://xxx/slack/cloud-build/message.json

  secrets:
    - name: webhook-url
      value: projects/xxx/secrets/xxx/versions/latest

@prabenzom
Copy link
Contributor

Hi, which version of the notifier are you using? I believe you need to be using 1.15 (or ideally latest) and you should get these errors resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants