Gitblit IRC Service Hook

79 views
Skip to first unread message

Christopher Lemire

unread,
May 3, 2013, 12:33:07 PM5/3/13
to git...@googlegroups.com
I've created an irc service hook that is similar to github's. This is what it looks like when github's irc service hook is called.


I've created this one for Gitblit, and it works. It's not complete yet. It only sends a test message to the channel. How can I get the same output from sendmail-html hook without the html (I will use irc codes for bold, coloring, etc)?

http://expectusafterlun.ch/gitblit/blob/?f=src/main/distrib/data/groovy/ircblit.groovy&r=IRCBlit.git&h=HEAD

I have released it under the Apache license in case GitBlit would like to include it.

Christopher Lemire <christoph...@gmail.com>
Fedora 64 bit Linux Raid Level 0

Gnu Privacy Guard Key Fingerprint = 32CA 0B0B 8A07 6969 7581 BD47 6053 3930 1D4B DC3E

Web: http://linuxinnovations.blogspot.com
Code: https://github.com/BullShark/JSpeak

James Moger

unread,
May 3, 2013, 1:28:31 PM5/3/13
to git...@googlegroups.com
Cool.  Have you triggered any of your System.exit() calls?  I'm not sure if Groovy Script Engine has any sort of special handling for that... does it terminate _just_ the GSE?  Or will it kill Gitblit too?

-J

Christopher Lemire

unread,
May 3, 2013, 4:21:21 PM5/3/13
to git...@googlegroups.com
No, an exception never was thrown that called a System.exit(). I just
put System.exit() at the beginning of the script to see what would
happen.

ERROR Failed to execute Groovy script ircblit.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:/usr/share/tomcat/webapps/gitblit/WEB-INF/data/groovy/ircblit.groovy:
426: unable to resolve class MarkupBuilder
@ line 426, column 16.
def builder = new MarkupBuilder(writer)

There was a lot more similar errors.

Actually it seemed to have killed Apache Tomcat all together. I could
not browse another webapp or gitblit. I looked at the catolina.out:

SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:499)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:371)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:458)

I've found a solution that works. I redefined the methods that would
call exit() return type's from void to boolean. If the method that
makes a connection to the server fails, it returns false. Then return;
is called from the constructor.

http://expectusafterlun.ch/gitblit/blob/?f=src/main/distrib/data/groovy/ircblit.groovy&r=IRCBlit.git&h=HEAD

I'm still needing help to get the git information, so that I can send
it to the irc channel with msgChannel() or noticeChannel(). Thanks.

Christopher Lemire

unread,
May 11, 2013, 6:45:15 AM5/11/13
to git...@googlegroups.com
When using Custom Fields that are required for the script to work
correctly, what will be returned (or an exception thrown maybe?) when
they are not defined in the gitblit.properties file, and what's the
best way to handle that?

Christopher Lemire

unread,
May 11, 2013, 6:49:41 AM5/11/13
to git...@googlegroups.com
For this groovy hook script, I need from custom fields:

debug (true or false)
irc server
irc port
irc channel

If debug is not set in gitblit.properties, I'd like to set it to false
by default. For all the others, there's not really a default value.
Those are required.

Christopher Lemire <christoph...@gmail.com>
Fedora 64 bit Linux Raid Level 0

Gnu Privacy Guard Key Fingerprint = 32CA 0B0B 8A07 6969 7581 BD47 6053
3930 1D4B DC3E

Web: http://linuxinnovations.blogspot.com
Code: https://github.com/BullShark/JSpeak


Reply all
Reply to author
Forward
0 new messages