GithubHelp home page GithubHelp logo

code-pipeline-slack's Introduction

Code Pipeline Slack Bot

This bot will notify you of CodePipeline progress (using CloudWatch Events).

We attempt to provide a unified summary, by pulling together multiple events, as well as information obtained by the API into a single message view.

Build

Launch

us-east-1 us-west-2
Launch Launch

Configuration / Customization

No configuration is necessary per pipeline. As part of the CF Stack, we subscribe to all CodePipeline and CodeBuild events (using CloudWatch Events).

When creating the CloudFormation stack, you can customize:

  • SlackChannel (defaults to builds).
  • SlackBotName (defaults to PipelineBuildBot).
  • SlackBotIcon (defaults to :robot_face: 🤖 ).

Additionally, you must provide both a SlackOAuthAccessToken and a SlackBotUserOAuthAccessToken, (see BotUsers for creating a slack bot user with an OAuth token). If you have the legacy integration token, just add that token to both fields. It is required to add the permission scope 'Access user’s public channels' (channels:history).

How it works

We utilize CloudWatch Events for CodePipline and CodeBuild to get notified of all status changes.

Using the notifications, as well as using the CodePipeline APIs, we are able to present a unified summary of your Pipeline and Build status.

IAM permissions

As part of the deployment, we create an IAM policy for the bot lambda function of:

Policies:
  - AWSLambdaBasicExecutionRole
  - Version: '2012-10-17'
    Statement:
      - Effect: Allow
        Action:
          - 'codepipeline:Get*'
          - 'codepipeline:List*'
        Resource: '*'
      - Effect: Allow
        Action:
          - 'codebuild:Get*'
        Resource: '*'

So we can retrieve information about all pipelines and builds. See template.yml for more detail.

code-pipeline-slack's People

Contributors

jamessoubry avatar ogrodnek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

code-pipeline-slack's Issues

Setup Bot

I cant find any documentation on how to get the bot installed onto slack. Do I make my own bot? Does it have any code associated with it? Is all I have to do is click on the Launch Stack button and input the correct information in AWS and then create my own bot with no funcitonality?

Slack Bot Not Updating Message

The Slack Bot I have configured, it is not updating (chat.update) the original message. It is posting a new message for each change in my pipeline. Your gif shows that it should be updating the original message as the steps are being executed in the pipeline.

Please advise.

Channel error

The SLACK_CHANNEL I put is a private channel in slack.

'channels': KeyError
Traceback (most recent call last):
  File "/var/task/notifier.py", line 98, in run
    m = process(event)
  File "/var/task/notifier.py", line 91, in process
    processCodePipeline(event)
  File "/var/task/notifier.py", line 56, in processCodePipeline
    existing_msg = find_message_for_build(buildInfo)
  File "/var/task/slack_helper.py", line 40, in find_message_for_build
    for m in find_my_messages("builds"):
  File "/var/task/slack_helper.py", line 28, in find_my_messages
    ch_id = find_channel(ch_name)
  File "/var/task/slack_helper.py", line 17, in find_channel
    for ch in r['channels']:
KeyError: 'channels'

image

image

Launch buttons outdated

I believe the templateURL doesn't have the latest changes of master branch. There's no SlackOAuthAccessToken or SlackBotUserOAuthAccessToken.

Non-Functional

This is unfortunately non functional.
The deploy buttons that trigger cloud formation directly are using a different version of code than the master branch. I have pulled down the master branch and tried to deploy it manually to cloud formation but there are so many dependency issues the lambda will not even run.

From the deploy button:

Response:
{
  "stackTrace": [
    [
      "/var/task/notifier.py",
      98,
      "run",
      "m = process(event)"
    ],
    [
      "/var/task/notifier.py",
      90,
      "process",
      "if event['source'] == \"aws.codepipeline\":"
    ]
  ],
  "errorType": "TypeError",
  "errorMessage": "list indices must be integers, not str"
}

From the master branch:

Response:
{
  "errorMessage": "Unable to import module 'notifier'"
}

Can not send Slack message

Hi there,

I have been setup Lambda and Codepipelines successfully and the Cloudwatch Event is working now. The Slack Tokens are work with #builds channel as well.

However, Lambda function seems not works, I always received an error message like this:

list indices must be integers, not str: TypeError
Traceback (most recent call last):
  File "/var/task/notifier.py", line 98, in run
    m = process(event)
  File "/var/task/notifier.py", line 90, in process
    if event['source'] == "aws.codepipeline":
TypeError: list indices must be integers, not str

Anyone knows why?

Thank you so much!

How to deploy on region eu-central-1

I tried to install it in our region eu-central-1 but I got the error he can't reach the bucket (because it's in region us-west-2).
can you also create a bucket with the files in the regio eu-central-1?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.