Skip to content

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

@TeChn4K

Description

@TeChn4K

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions