Slack integration for Google Cloud Build, using Google Cloud Functions to post messages to Slack when a build reaches a specific state.
The webhook needs configuration parameters that are given setting the following environment variables:
SLACK_WEBHOOK_URL
: you can find it in here: https://growkudos.slack.com/services/B68AXU94J#service_setup in the Setup Instructions section.GCP_REGION
GITHUB_TOKEN
: you can find it in the info.txt file in gocrypto-fs looking for the wordGITHUB_CI_TOKEN_GCB
Terraform has been used to create the Cloud Function and set up the environment to run it (note: it will also set the environment variables). Also, a Google Cloud Build trigger has been manually set up to automatically run the tests and the terraform script to create or update the Cloud Function when changes are pushed to this repository. The manual configuration of the trigger includes setting up the configuration parameters described in the previous section.
Each build invokes 3 times the function:
- when the build is queued
- when the build starts
- when the build reaches a final status.
Here is the GCF pricing for calculation.
Just change the function code, update the tests as needed and push it to master. The Google Cloud Function will be automatically updated if the pipeline runs successfully.
For github commit author info to be displayed, the cloud source repositories must be in the form of github_<OWNER>_<REPO>
and there cannot be underscores in either <OWNER>
or <REPO>
. A possible solution to bypass this limitation would be to retrieve owner and repo info directly from GitHubEventsConfig.