RedMine集成企业微信通知
如果Redmine版本是低于5.0的,可以用下面这个插件,这个插件不仅支持企业微信,还支持钉钉通知
https://www.redmineplugins.cn/projects/1/plugin_blocks/70?tab=installation_notes
效果如下:
消息模板修改,上面的通知消息太简单了,我们可以自定义一下。我们先到插件目录下,进入到/lib/redmine_qy_wechat/patches
修改issues_controller_patch.rb和corp_wechats_journals_patch.rb的
send_by_wechat(send_people_wx)方法
corp_wechats_journals_patch.rb的33行,把原来的注释掉,用自己定义的模板
if @group_client.is_valid? #options = {access_token: "access_token"} # redis_key 也可定制 #group_client = QyWechatApi::Client.new(corpid, corpsecret, options) #issue #填写确认并应用的应用AgentId issue_link = "#{Setting.protocol}://#{Setting.host_name}/issues/#{@issue.id}" subject = @issue.subject updated_by = @issue.journals.last.user #notes = @issue.journals.last.notes.sub('<br>', '\n').sub('<br />', '\n').gsub(/<\/?.*?>/, "")[0, 450] message_content = <<~MESSAGE 您Redmine的任务已更新: **任务标题** : <a href='#{issue_link}'>#{subject}</a> **任务ID** : ##{@issue.id} **更新人** : #{updated_by} **查看详情** : <a href='#{issue_link}'>点击这里</a> MESSAGE @group_client.message.send_text(send_people_wx, "", "", app_id, message_content) #@group_client.message.send_text(send_people_wx, "", "", app_id, #"#{l(:msg_focus)} <a href=\'" + Setting.protocol + "://" + Setting.host_name + "/issues/#{@issue.id}\'>#{@issue.tracker} ##{@issue.id}: #{@issue.subject}</a>\n#{(@issue.journals.last.notes).sub('<br>','\n').sub('<br />','\n').gsub(/<\/?.*?>/,"")[0,450]}\n#{l(:msg_by)} <a href=\'javascript:void(0);\'>#{@issue.journals.last.user}</a> #{l(:msg_updated)}") end
issues_controller_patch.rb的45行
if @group_client.is_valid? #options = {access_token: "access_token"} # redis_key 也可定制 #group_client = QyWechatApi::Client.new(corpid, corpsecret, options) #issue #填写确认并应用的应用AgentId message_content = <<~MESSAGE 任务更新通知: **任务标题**: #{@issue.subject} **任务状态**: #{@issue.status.name} **更新人**: #{@issue.author} **链接**: <a href='#{Setting.protocol}://#{Setting.host_name}/issues/#{@issue.id}'>查看任务</a> MESSAGE @group_client.message.send_text(send_people_wx, "", "", app_id, message_content) #@group_client.message.send_text(send_people_wx, "", "", app_id,"#{l(:msg_focus)} <a href=\'" + Setting.protocol + "://" + Setting.host_name + "/issues/#{@issue.id}\'>#{@issue.tracker} ##{@issue.id}: #{@issue.subject}</a> #{l(:msg_by)} <a href=\'javascript:void(0);\'>#{@issue.author}</a> #{l(:msg_created)}") end
然后重新启动一下redmind
效果如下:
如果版本是高于5.0的,可以用下面这个插件
https://www.redmineplugins.cn/projects/1/plugin_blocks/157?tab=installation_notes