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

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

Examples

# send a message to googleAuthRverse Slack webhook <- "https://hooks.slack.com/services/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" cr_buildstep_slack("Hello Slack", webhook = webhook)
#> [[1]] #> ==cloudRunnerBuildStep== #> name: technosophos/slack-notify #> env: #> - SLACK_WEBHOOK=https://hooks.slack.com/services/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 #> - SLACK_MESSAGE='Hello Slack' #> - SLACK_TITLE='CloudBuild - $BUILD_ID' #> - SLACK_COLOR='#efefef' #> - SLACK_USERNAME='googleCloudRunnerBot' #>
if (FALSE) { bs <- cr_build_yaml(steps = cr_buildstep_slack("Hello Slack")) cr_build(bs, substitutions = list(`_SLACK_WEBHOOK` = webhook)) }