Skip to content

Google Cloud Build notifications in Slack using Cloud Function

License

Notifications You must be signed in to change notification settings

onsails/cloudbuild-slack

Repository files navigation

Google Cloud Function sending Cloud Build statuses to a Slack channel, written in TypeScript

Features:

  • send slack notifications about successful and failed builds;
  • link to build details in slack message;
  • no need in additional step in cloudbuild.yaml;
  • report success and failure statuses;
  • show trigger information in slack message;
  • customize slack message using substitution in cloudbuild.yaml.

Slack message Slack message

Deploy

Prerequisites:

  • Google Cloud Platform project with enabled Cloud Functions API;
  • gcloud command-line util authorized to deploy cloud functions;
  • Slack webhook url.

Deployment:

SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR_TOKENS ./deploy.sh

This script will deploy cloud function gcbSubscribeSlack triggered by cloud-build PubSub topic.

Message content can be (optionally) defined by _SLACK_MESSAGE_TEMPLATE substitution in cloudbuild.yaml. Value should be a valid ejs template:

steps:

# ... build steps ...

substitutions:
  _SLACK_MESSAGE_TEMPLATE: '<%= emoji %> *https://<%= build.substitutions._OVERLAY %>.example.com* frontend build & deploy `<%= build.id %>` <%= build.status %>'

emoji corresponds to a build status, build is object containing build information, it's structure is defined here.

The default message template is <%= emoji %> `<%= build.id %>` <%= build.status %>

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •