Bern is a simplistic cloud bot to perform annoying tasks such as logging hours in Redmine
-
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.
-
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
orsource ~/.bash_profile
- run bern command
- if you can see the list of commands, you are good to go
# with comments bern redmine_log_hours -c my comments here # with custom date bern redmine_log_hours -d 2016-06-24
bern set_env -e activity_id -v 1
SMTP SERVER, SET ENV VARS, NEWRELIC APP
You need to setup a smtp server and set the env vars
You need to get your smtp servers settings and set as env vars
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
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:
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
-
Fork and clone this repo
-
Go to the root folder
-
Install the heroku toolbelt (https://toolbelt.heroku.com/)
-
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
-
Add New Relic:
$ heroku addons:create newrelic:wayne
-
Add a SMTP server:
$ heroku addons:create sendgrid:starter
-
Add a scheduler:
$ heroku addons:create scheduler:standard
-
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.
-
Go to https://dashboard.heroku.com/apps, find your app and click on it, look for the list of addons and open 'Heroku Scheduler'
-
Enter the name of ruby script 'redmine_log_hours' in the blank space, and set the frequency of your schedule.
-
Your app should be running in in heroku: app_name.heroku.com
Yes you can. Please fork this repo and send me the pull request.