Slack integration for Google Cloud Container Builder, using Google Cloud Functions
APACHE-2.0 License
Slack integration for Google Cloud Build, using Google Cloud Functions to post messages to Slack when a build reaches a specific state.
export SLACK_WEBHOOK_URL=my-slack-webhook-url
PROJECT_ID
variable:export PROJECT_ID=my-project-id
export GITHUB_TOKEN=my-token
export GC_SLACK_STATUS="SUCCESS FAILURE TIMEOUT INTERNAL_ERROR"
BUCKET_NAME
and a FUNCTION_NAME
.. ./setup.sh
# OR
npm run setup
serverless
npm install serverless -g
Ensure that the value of project.credentials
in serverless.yml
points to credentials with appropriate roles Serverless can use to create resources in your Project.
serverless deploy
The teardown script will delete the function FUNCTION_NAME
, and the bucket BUCKET_NAME
.
. ./teardown.sh
# OR
npm run teardown
serverless remove
Each build invokes 3 times the function:
Here is the GCF pricing for calculation.
Yes if deploying with the setup script, specify the BUCKET_NAME
:
exports BUCKET_NAME=my-bucket
If deploying with the serverless framework however, this option is not yet available in the Google Cloud Functions provider plugin, but hopefully will be in the near future as an issue has been opened.
If you use the setup script with the same FUNCTION_NAME
, it will update the existing function.
If you use serverless, simply re running serverless deploy
will update the existing function.
SLACK_WEBHOOK_URL
?After creating an application on Slack, active the Incoming Webhooks. You'll find the url on that page:
In the case where a BUCKET_NAME
is not defined, a random one is generated. And in order to delete it during the teardown, the variable has to be exported from the setup script.
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.