A jira notification system for irc using camel

Last week, I thought that it would be a nice idea to have JIRA notifications for our Apache projects on IRC (for projects that sometimes use an IRC channel). So I came up with a very simple solution using Camel deployed on top of Karaf.

The application itself consists in a single xml file to be copied in the deploy folder of your Karaf installation. This was one of my requirements for ease of maintenance. This is possible because of the nice hot deployment mechanism for spring xml applications in Karaf.

Now, if you log onto the #camel, #cxf, #servicemix or #activemq IRC channels, you'll see some messages that look like:

jirabot: Claus Ibsen - Created: (CAMEL-2090) camel-jms -
Option autoStartup does not work
(see https://issues.apache.org/activemq/browse/CAMEL-2090 )

Those are all generated by the following applications:

<beans xmlns="http://www.springframework.org/schema/beans"


<camelContext xmlns="http://camel.apache.org/schema/spring">
<from uri="imaps://imap.gmail.com:993?username=xxx&amp;password=xxx&amp;consumer.delay=1000&amp;delete=false" />
<convertBodyTo type="java.lang.String"/>
<!-- Remove any cr/lf that would cause regexp to not work -->
<setHeader headerName="tmpsubject">
request.headers.subject.replaceAll("\r\n", " ").replaceAll("\r|\n", "")
<!-- Extract the user name from the from header -->
<setHeader headerName="tmpfrom">
request.headers.from.replaceAll(".*\"(.*)\".*", "$1").replace("(JIRA)", "")
<!-- Camel -->
<setHeader headerName="irc.target">
<setHeader headerName="issuelink">
" (see https://issues.apache.org/activemq/browse/" +
request.headers.tmpsubject.replaceAll(".*jira.*(CAMEL-[0-9]+).*", "$1") +
" )"
<!-- other projects filtering using the exact same mechanism -->
<!-- Other non jira emails -->
request.headers.from + ": " + request.headers.tmpsubject
<setHeader headerName="irc.target">
request.headers.tmpfrom + "- " +
request.headers.tmpsubject.replace("[jira]", "") +
<to uri="irc:irc.codehaus.org/?nickname=jirabot&username=jirabot" />


This has been a small and enjoyable exercise. Camel rocks!


Anonymous said…
Big thanks for this! Really helped me..

Popular posts from this blog

Apache Karaf

Camel Endpoint DSL

ActiveMQ Pooling