Skip to content

Instantly share code, notes, and snippets.

@panbanda
Created August 20, 2015 11:26
Show Gist options
  • Save panbanda/997048d3dd99bf8aec74 to your computer and use it in GitHub Desktop.
Save panbanda/997048d3dd99bf8aec74 to your computer and use it in GitHub Desktop.
Slack Redmine Upcoming Deadlines
require 'rubygems'
require 'active_resource'
require "uri"
require "net/http"
slack = 'https://hooks.slack.com/services/XXX/XXX/XXX'
# Issue model on the client side
class Issue < ActiveResource::Base
self.site = 'https://redmine.stepfeed.com/'
self.user = 'XXX'
self.password = 'XXX'
self.format = :xml
end
def permalink(issue)
"https://redmine.stepfeed.com/issues/%i" % issue.id
end
# Retrieving issues
issues = Issue.all(:params => { due_date: '><%s|%s' % [Date.current, Date.current + 1.week] })
text = "Goood morning @everyone! Here is what is on tap this week in case you want to know.\n\n"
issues.each do |i|
text += "<%s|%s> (%s)\n" % [permalink(i), i.subject, i.project.name]
end
payload = {
username: 'Redmine',
icon_url: 'https://raw.github.com/sciyoshi/redmine-slack/gh-pages/icon.png',
channel: '#redmine',
text: text,
mrkdwn: true
}.to_json
Net::HTTP.post_form(URI.parse(slack), { payload: payload });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment