All Projects → ahelal → bender

ahelal / bender

Licence: MIT license
A Concourse resource that can trigger and pass parameters to jobs using slack

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to bender

concourse-git-bitbucket-pr-resource
🚀 Concourse CI resource for tracking git branches of Bitbucket pull-requests
Stars: ✭ 29 (-9.37%)
Mutual labels:  concourse, concourse-ci, concourse-resource, concourse-ci-resource
concourse-build-resource
A Concourse resource for observing Concourse builds
Stars: ✭ 16 (-50%)
Mutual labels:  concourse, concourse-ci, concourse-resource, concourse-ci-resource
ofcourse
A Concourse resource generator
Stars: ✭ 41 (+28.13%)
Mutual labels:  concourse, concourse-ci, concourse-ci-resource
concourse-fly-resource
A Concourse resource for manipulating fly
Stars: ✭ 16 (-50%)
Mutual labels:  concourse, concourse-ci, concourse-resource
pulumi-resource
Pulumi Resource Type for Concourse
Stars: ✭ 16 (-50%)
Mutual labels:  concourse, concourse-resource
keyval-resource
a resource that passes key values between jobs
Stars: ✭ 39 (+21.88%)
Mutual labels:  concourse, concourse-ci
maven-resource
Maven Repository Manager Concourse Resource
Stars: ✭ 22 (-31.25%)
Mutual labels:  concourse, concourse-resource
cogito
Another Concourse GitHub status resource
Stars: ✭ 21 (-34.37%)
Mutual labels:  concourse, concourse-resource
ansible-concourse
An ansible role to manage Concourse CI
Stars: ✭ 22 (-31.25%)
Mutual labels:  concourse, concourse-ci
terraform-aws-concourse
Terraform Module for a distributed concourse cluster on AWS
Stars: ✭ 12 (-62.5%)
Mutual labels:  concourse, concourse-ci
cog-helm
A Helm chart to deploy Cog on Kubernetes
Stars: ✭ 17 (-46.87%)
Mutual labels:  chatops
gort
Gort is a chatbot framework designed from the ground up for chatops.
Stars: ✭ 381 (+1090.63%)
Mutual labels:  chatops
terraform-provider-concourse
A terraform provider for Concourse
Stars: ✭ 49 (+53.13%)
Mutual labels:  concourse
slash-heroku
/heroku commands for slack
Stars: ✭ 37 (+15.63%)
Mutual labels:  chatops
chatops-controller
A rails plugin to make creating chatops easy
Stars: ✭ 58 (+81.25%)
Mutual labels:  chatops
chef-lita
A Chef cookbook for installing Lita.
Stars: ✭ 17 (-46.87%)
Mutual labels:  chatops
paas-templates
Bosh, CFAR, CFCR and OSB services templates for use with COA (cf-ops-automation) framework
Stars: ✭ 16 (-50%)
Mutual labels:  concourse
concourse-ci-formula
All-in-one Concourse VM with S3-compatible storage and Vault secret manager
Stars: ✭ 26 (-18.75%)
Mutual labels:  concourse
gcs-resource
Concourse resource for interacting with Google Cloud Storage
Stars: ✭ 33 (+3.13%)
Mutual labels:  concourse
trax
Simple time tracker designed for ChatOps
Stars: ✭ 40 (+25%)
Mutual labels:  chatops

Bender concourse resource

Build Status Docker Repository on Quay

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.

Deploying to Concourse

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

Source Configuration

  • 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, default bender. 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., default true. By default use the authed user, if false you can customize the bot_name, bot_icon_emoji and bot_icon_ur.

  • bot_icon_emoji: Optional. Emoji to use as the icon for this message. Overrides bot_icon_url. Must be used in conjunction with as_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 with as_user set to false, otherwise ignored.

  • mention: Optional. Only respond to mention @bot_name this will only work with as_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 to template_filename can be used as an input file for further jobs in the pipeline.

  • template_filename: Optional, default template_file.txt. The file name for a generated template.

  • slack_unread: Optional, default false. 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.

Behavior

check: Check for new messages that match the rules

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 selected channel.

  • If grammar is defined, it must match the regular expression defined in grammar.

check Parameters

Check accepts no params.

in: Get the message

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 Parameters

In accepts no params.

out: Reply to original message

Replies with a message to the selected channel.

out Parameters

  • reply: Required/optional. A string or file path to be used as reply. Supports template format. Must be defined if reply_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 if reply is not defined.

  • reply_thread: optional, default False. 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.

Template

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.

Tips

  • 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.

TODO

  • Increase code coverage
  • Restrict per user_group
  • lock example

Contribution

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].