A Concourse resource that can trigger any job (deployments, releases, ...) using slack.
Check examples page for usage.
NOTE: Bender is still young, Your input and contribution is highly appreciated.
You can use the docker image by defining the resource type in your pipeline YAML.
resource_types :
- name: bender-resource
type: docker-image
source:
repository: quay.io/ahelal/bender
tag: latest
-
slack_token
: Required. The slack token to be used. For more info check slack documentation. -
channel
: Required. The channel name to be used by the bot. -
bot_name
: Optional, defaultbender
. The bot name will be used to identify and filter messages. All messages must be addressed to the bot, eg.:@bot_name some message
. -
as_user
: Optional., defaulttrue
. By default use the authed user, iffalse
you can customize thebot_name
,bot_icon_emoji
andbot_icon_ur
. -
bot_icon_emoji
: Optional. Emoji to use as the icon for this message. Overridesbot_icon_url
. Must be used in conjunction withas_user
set to false, otherwise ignored. -
bot_icon_url
: Optional. URL to an image to use as the icon for this message. Must be used in conjunction withas_user
set to false, otherwise ignored. -
mention
: Optional. Only respond to mention@bot_name
this will only work withas_user: false
, otherwise ignored. -
grammar
: Optional. If not defined bender will respond to all mentions@bot_name
and If grammar is defined bender will only respond to messages matching the regex expression. Use python regular expression syntax. See examples page for inspiration. -
template
: Optional. A string that will be evaluated and written totemplate_filename
can be used as an input file for further jobs in the pipeline. -
template_filename
: Optional, defaulttemplate_file.txt
. The file name for a generated template. -
slack_unread
: Optional, defaultfalse
. If set to true, The state of slack unread message will be used instead of of the last version reported by concourse. This will improve speed, but downside you can't have multiple triggers per channel with same token and it's non-standard concourse behavior. This only affects the check method.
Check will report a new version;timestamp
; if message fits all the criteria.
-
If
mention
is true the message must be addressed to@bot_name
in the selectedchannel
. -
If
grammar
is defined, it must match the regular expression defined ingrammar
.
Check accepts no params.
A file bender.json will be created with the message payload.
if template
is defined it will be evaluated and written to template_filename
. For more info on template syntax read template section. For example on usage, check the examples page.
In accepts no params.
Replies with a message to the selected channel
.
-
reply
: Required/optional. A string or file path to be used as reply. Supports template format. Must be defined ifreply_attachments
is not defined. -
reply_attachments
: Required/optional. A string or JSON file path to be used as reply in slack attachment format. You can use messages builder Supports template format. Must be defined ifreply
is not defined. -
reply_thread
: optional, defaultFalse
. If enabled will post reply to original message as a thread. -
path
: required. The path of the resource name. This is used to get context from original message.
The template uses python Jinja2 engine.
-
variables
: You can access variables using curly braces{{ VARIABLE_NAME }}
. All environmental variables are accessible through{{ ENV['PATH'] }}
. Concourse exposes some metadata info like job_name, build, for more info check concourse website. The regex groups are accessible to the template engine as{{ regex }}
if you used subgroups in your expression you can access each group with index{{ regex[0] }}
. If you used named subgroups you can access them as dictionary{{ regex['name'] }}
. The original user who initiated the trigger is accessible as variable{{ user }}
. You can also add@{{ user }}
to mention the user. -
white spaces
: You can use\n
for new lines\t
for tabs in your template. -
filters
: You can use Jinja2 builtin filters.
-
Test your regex using something like regexr.com, it is better to use named subgroups.
-
Note that you need to escape the backslash with another backslash in yaml, eg.:
\s+
should be\\s+
-
Use
\s+
between commands to give a little bit of room for user send an extra space in the message. -
You probably want to define version: every and trigger: true so the resource will go through all the messages and trigger the jobs.
- get: bender
version: every
trigger: true
- By default concourse resource are checked every 1m. If you want to setup multi resources you will exhaust your Slack API limits fast. You can configure slack to do an API call to your concourse using slack outgoing webhooks, concourse webhook_token and increase check_every to higher eg. 1h. You can also use different Slash commands instead of web hooks.
- Increase code coverage
- Restrict per user_group
- lock example