Skip to content

a custom implementation of gocd notification email parser to be sent to slack

License

Notifications You must be signed in to change notification settings

aaira-a/gocd2gmail2slack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

I have blogged about the background and motivations for this package:

http://azam-a.github.io/Email-to-Slack-Notifier-Using-Python/

Of course there are more elegant solutions like gmail2slack or gocd-slack-build-notifier, but in cases of permission constraints to the gocd environment and the only available channel is email, then maybe this solution is acceptable. Nevertheless, it was a good learning exercise for me.

How to use

  1. Turn on Gmail API for a Google Account (instructions Step 1) and get the client_secret.json to register the app

  2. Clone this repo

  3. In activated virtualenv session (or global environment), install required packages from requirements.txt:

    pip install -r requirements.txt
    
  4. Edit config.py to include Slack Incoming Webhook and GoCD dashboard URLs (template)

  5. Edit config.py to define CI_STAGES and DEPLOY_STAGES in a form of list of string. These definitions are used by sending rule as well as changeset-exclusion logic in slack.py

  6. Paste the client_secret.json from Step 1 into the cfg folder

  7. cd into the gocd2gmail2slack directory (which contains integrations.py)

  8. (optional) To run tests, run python -m unittest from the same directory as Step 7

  9. Create a Gmail label 'SENT_TO_SLACK' at the intended Gmail account

  10. run python integrations.py

  11. The first run will open a browser to authenticate and authorize a Gmail account

  12. The credentials will be saved to cfg/cred/saved_credentials.json for subsequent runs

  13. The script will query all the 'UNREAD' emails and process them accordingly

  14. Schedule the running of python integrations.py every X minutes using Task Scheduler or Cron

About

a custom implementation of gocd notification email parser to be sent to slack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages