bernEsp / bern

cloud bot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bern

Bern is a simplistic cloud bot to perform annoying tasks such as logging hours in Redmine

How can I use it?

  1. Heroku or background job

    Bern bot contains a ruby script that you can run every day or create a background job that run for you at certain hour.

  2. Bern Cli

    Bern bot now have cli app that can be use locally. This cli allows you customize comments and date. You still need to export environment variables to keep secret your sensitive info.

    • Download the code
    • add to your bashrc or bash_profile export PATH="$HOME/canino_projects/bern/bin:$PATH"
    • reload your terminal source ~/.bashrc or source ~/.bash_profile
    • run bern command
    • if you can see the list of commands, you are good to go
    redmine log hours
      # with comments
      bern redmine_log_hours -c my comments here
      # with custom date
      bern redmine_log_hours -d 2016-06-24
    set environment variable
      bern set_env -e activity_id -v 1

Requeriments

SMTP SERVER, SET ENV VARS, NEWRELIC APP

locally

You need to setup a smtp server and set the env vars

HOST REMOTELY

You need to get your smtp servers settings and set as env vars

Logger

Bern performs a task to logs hours in redmine, therefore you need a little bit of configuration and settings and payload of your **REDMINE SERVER

ENV VARS

COMPANY HOLIDAYS: HOLIDAYS list of holidays in this format 'yyyy-mm-dd' divided by comma

SMTP SERVER:

SENDGRID_PASSWORD:     smtp password
SENDGRID_USERNAME:     smtp username
SMTP_DELIVERY_EMAIL:   notification email
SMTP_DOMAIN:           smtp server domain
SMTP_HOST_EMAIL:       host email, your server email for example 'username@bern.heroku.com'
SMTP_PORT:             smtp port
SMTP_SERVER:           smtp host

REDMINE:

ACTIVITY_ID:           redmine activity id
HOURS:                 number of hours
ISSUE_ID:              issue id
THIRD_PARTY_KEY:       redmine api key
THIRD_PARTY_URL:       redmine url
# optional
COMMENTS               redmine random comments divided by semicolon

NEWRELIC:

NEW_RELIC_APP_NAME:    newrelic app name
NEW_RELIC_LICENSE_KEY:
NEW_RELIC_LOG:

HOW AM I USING IT?

I've uploaded bern to a heroku app. I've added the scheduler addon and setup to run every day the script redmine_log_hours

I've also added newrelic and send grid addons

Heroku automatically setup for you all env vars as bern requires, then I've just setup the env vars for redmine.

Bern is logging to redmine using the redmine api

Instructions for heroku (thanks @Ivanknmk)

  1. Fork and clone this repo

  2. Go to the root folder

  3. Install the heroku toolbelt (https://toolbelt.heroku.com/)

  4. Run this in the folder where you cloned the project to create a heroku app: $ heroku login (and enter your heroku credentials)

    $ heroku create

    $ git push heroku master

  5. Add New Relic:

    $ heroku addons:create newrelic:wayne

  6. Add a SMTP server:

    $ heroku addons:create sendgrid:starter

  7. Add a scheduler:

    $ heroku addons:create scheduler:standard

  8. Setup the env vars:

Run heroku config. You should have already the SENDGRID_PASSWORD, SENDGRID_USERNAME & NEW_RELIC_LICENSE_KEY, so please set these variables:

    $ heroku config:set SMTP_DELIVERY_EMAIL=#{EMAIL_TO_RECEIVE_NOTIFICATIONS}
    
    $ heroku config:set SMTP_PORT=#{SMPT_PORT}
    
    $ heroku config:set SMTP_DOMAIN=#{HOST_DOMAIN}
    
    $ heroku config:set SMTP_SERVER=#{SMTP_ADDRESS}
    
    $ heroku config:set SMTP_HOST_EMAIL=#{YOUR_EMAIL}
    
    $ heroku config:set NEW_RELIC_APP_NAME=#{APP_NAME}

    $ heroku config:set ACTIVITY_ID=#{ID}
    
    $ heroku config:set HOURS={HOURS}
    
    $ heroku config:set ISSUE_ID=#{ISSUE_ID_IN_REDMINE}
    
    $ heroku config:set THIRD_PARTY_KEY=#{API_KEY}
    
    $ heroku config:set THIRD_PARTY_URL=#{REDMINE_URL}/time_entries.json

If you find something like this #{SOMETHING_HERE} it means that a user input is required. So please look for the information required and substitute that string with the one you want.

  1. Go to https://dashboard.heroku.com/apps, find your app and click on it, look for the list of addons and open 'Heroku Scheduler'

  2. Enter the name of ruby script 'redmine_log_hours' in the blank space, and set the frequency of your schedule.

  3. Your app should be running in in heroku: app_name.heroku.com

Can I improve this awesome tool? Is it possible to collaborate?

Yes you can. Please fork this repo and send me the pull request.

About

cloud bot


Languages

Language:Ruby 100.0%