cr_buildstep_slack: Send a Slack message to a channel from a Cloud Build step

View source: R/buildsteps_templates.R

cr_buildstep_slackR Documentation

Send a Slack message to a channel from a Cloud Build step

Description

This uses https://github.com/technosophos/slack-notify to send Slack messages

Usage

cr_buildstep_slack(
  message,
  title = "CloudBuild - $BUILD_ID",
  channel = NULL,
  username = "googleCloudRunnerBot",
  webhook = "$_SLACK_WEBHOOK",
  icon = NULL,
  colour = "#efefef"
)

Arguments

message

The body of the message

title

The title of the message

channel

The channel to send the message to (if omitted, use Slack-configured default)

username

The name of the sender of the message. Does not need to be a "real" username

webhook

The Slack webhook to send to

icon

A URL to an icon (squares between 512px and 2000px)

colour

The RGB colour for message formatting

Details

You will need to set up a Slack webhook first, via this Slack guide on using incoming webhooks.

Once set, the default is to set this webhook to a Build macro called _SLACK_WEBHOOK, or supply it to the webhook argument.

See Also

Other Cloud Buildsteps: cr_buildstep_bash(), cr_buildstep_decrypt(), cr_buildstep_df(), cr_buildstep_docker(), cr_buildstep_edit(), cr_buildstep_extract(), cr_buildstep_gcloud(), cr_buildstep_gitsetup(), cr_buildstep_mailgun(), cr_buildstep_nginx_setup(), cr_buildstep_packagetests(), cr_buildstep_pkgdown(), cr_buildstep_run(), cr_buildstep_r(), cr_buildstep_secret(), cr_buildstep_targets(), cr_buildstep()

Examples

# send a message to googleAuthRverse Slack
webhook <-
  "https://hooks.slack.com/services/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"
cr_buildstep_slack("Hello Slack", webhook = webhook)
## Not run: 

bs <- cr_build_yaml(steps = cr_buildstep_slack("Hello Slack"))

cr_build(bs, substitutions = list(`_SLACK_WEBHOOK` = webhook))

## End(Not run)


googleCloudRunner documentation built on March 18, 2022, 8 p.m.