Skip to content

Notifier images for Cloud Build, complete with build status filtering and Google Secret Manager integration

License

Notifications You must be signed in to change notification settings

NandosUK/cloud-build-notifiers

 
 

Repository files navigation

Cloud Build Notifiers

This repo provides deployable notifier images and sources, as well as libraries for creating new notifiers.

Cloud Build notifiers are Docker containers that connect to the Cloud Build Pub/Sub topic that adapt Pub/Sub messages about Build update notifications to other services/protocols, such as SMTP for email. Cloud Build notifiers are long-lived binaries that receive notifications throughout Builds' lifecycles (e.g. from the Build starting to execute through the Build finishing).

All notifiers can be built by Cloud Build and deployed on Cloud Run. The only prerequisite is to be a Cloud Build user and to have the gcloud CLI tool installed and configured for your Cloud Build project(s).

There are currently 3 supported notifier types:

  • bigquery, which writes Build updates and related data to a BigQuery table.
  • http, which sends (HTTP POSTs) a JSON payload to another HTTP endpoint.
  • slack, which uses a Slack webhook to post a message in a Slack channel.
  • smtp, which sends emails via an SMTP server.

See the official documentation on Google Cloud for how to configure each notifier:

Setup Script

A setup script exists that should automate most of the notifier setup.

Run ./setup.sh --help for usage instructions.

Common Flags

The following are flags that belong to every notifier via inclusion of the lib/notifiers library.

--smoketest

This flag starts up the notifier image but only logs the notifier name (via type) and then exits.

--setup_check

This flag starts up the notifier, which does the following:

  1. Read the notifier configuration YAML from STDIN.
  2. Decode it into a configuration object.
  3. Attempt to call notifier.SetUp on the given notifier using the configuration and a faked-out SecretGetter.
  4. Exit successfully unless one of the previous steps failed.

This can be done using the following commands:

# First build the notifier locally.
$ sudo docker build . \
    -f=./${NOTIFIER_TYPE}/Dockerfile --tag=${NOTIFIER_TYPE}-test
# Then run the `setup_check` with your YAML.
# --interactive to allow reading from STDIN.
# --rm to clean/remove the image once it exits.
$ sudo docker run \
    --interactive \
    --rm \ 
    --name=${NOTIFIER_TYPE}-test \
    ${NOTIFIER_TYPE}-test:latest --setup_check --alsologtostderr -v=5 \
    < path/to/my/config.yaml 

License

This project uses an Apache 2.0 license.

Contributing

See here for contributing guidelines.

Support

There are several ways to get support for issues in this project:

Note: Issues filed in this repo are not guaranteed to be addressed. We recommend filing issues via the Issue Tracker.

About

Notifier images for Cloud Build, complete with build status filtering and Google Secret Manager integration

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 88.7%
  • Dockerfile 5.9%
  • Shell 5.4%