Updated TeamCity WebHooks plugin available

4 07 2009

Version 0.6.13.11 of the tcWebHooks plugin is available for download. It’s mainly a bugfix release and some tidy up of the user interface.

Fixes:
- Fix for newly created WebHooks not being persisted to plugin-settings.xml until re-edited.
- Plugin JSPs loaded using getPluginResourcesPath(), so plugin dir can be anything, and not hard-coded to “webhook”.
- webHookUrl form input style fix for linux (or large fonts in general). URL input field was too wide for div.

Features:
- WebHook blurb updated. A new link can be added to the “Further reading” section of the blurb by adding a <info> line to the <webhooks> section of the main-config.xml
- Enabled events are now listed in Tabs and Edit pages, eg. Build Started, Build Changed Status, Build Interrupted, Build Almost Completed, Build Responsibility Changed

Links:

More Info | Download | Install and usage docs

I welcome any and all feedback.





Developing for TeamCity in Eclipse

28 06 2009

This document assumes you are running the TeamCity package from JetBrains, which includes Tomcat. If you are running your own Tomcat install, you may need to hunt out the files yourself. This document is based on Linux. I’ve tried to point out what you need to change on Windows, but I don’t have a Windows box to test with.

My TeamCity home  is /opt/TeamCity

Enable JSP development mode in Tomcat.

This setting alows you to hot delpoy JSPs, and Tomcat will re-compile them for you without a restart.  Edit <TeamCityHome>/conf/web.xml and find the JspServlet section. Change the development mode to true as per the section below.

<servlet-name>jsp</servlet-name>
   <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
     <init-param>
       <param-name>development</param-name>
       <param-value>true</param-value>
     </init-param>
  ...

Enable Java code hot-swapping with a debugger

We have enabled JSP hot-compile in the previous, now we need to configure Tomcat so that Eclipse can load new Java code into the JVM from within the Eclipse debugger.

For Linux, edit <TeamCityHome>/bin/teamcity-server.sh and insert the commands needed to start Tomcat with the debugger enabled. I added the TEAMCITY_DEBUG_OPTS variable, and then added it to the CATALINA_OPTS line.

TEAMCITY_DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"

 CATALINA_OPTS="$CATALINA_OPTS $TEAMCITY_SERVER_OPTS $TEAMCITY_DEBUG_OPTS -server $TEAMCITY_SERVER_MEM_OPTS -Dlog4j.configuration=file:$BIN/../conf/teamcity-server-log4j.xml -Dteamcity_logs=../logs/ -Djava.awt.headless=true"

For Windows, edit <TeamCityHome>\conf\teamcity-server.bat and insert the debug commands. I added the TEAMCITY_DEBUG_OPTS variable, and then added it to the CATALINA_OPTS line.

:server_mem_opts_done
SET TEAMCITY_DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
SET CATALINA_OPTS=%TEAMCITY_SERVER_OPTS% %TEAMCITY_DEBUG_OPTS% -server %TEAMCITY_SERVER_MEM_OPTS_ACTUAL% -Dlog4j.configuration=file:../conf/teamcity-server-log4j.xml -Dteamcity_logs=../logs/

Start Tomcat

Stop Tomcat if it’s running and then start it by running <TeamCityHome>/bin/teamcity-server.sh start (or <TeamCityHome>\bin\teamcity-server.bat start on Windows).

Have a look in <TeamCityHome>/logs/catalina.out  There should be a line similar to the one below indicating that Tomcat is running with the debug port open.

Listening for transport dt_socket at address: 8000

Configure Eclipse

In Eclipse, create a new Debug Configuration (In the Java perspective, it’s under the Run menu).

Find Remote Java Application, and click the new button.  In the Connect tab, set:

  • Connection Type: Standard Socket (Attach)
  • Connection Properties:
    • Host: localhost (assuming your TeamCity instance is on your local machine)
    • Port: 8000

In the Source tab, I added my Java source directory.

Connect to Tomcat in Eclipse

Run the new Debug Config, and change to the Debug perspective. A quote from the TeamCity dev page is relevant here.

if you do not change code affecting plugin initialization and change only body of the methods, you can attach to the server process with a debugger and hot-swap the code

So if you change your registers or constructors, you need to restart Tomcat.

Deploy your JSPs

When TeamCity starts, it copies the JSPs from your plugin into <TeamCityHome>/webapps/ROOT/plugins/<YourPluginName>/

Therefore, you can copy updated JSPs to here. This might be best acheived with a simple ANT script.





TeamCity WebHooks plugin beta available

22 06 2009

Announcing a beta release (version 0.5.5.5) of a plugin for TeamCity which enhances TeamCity to provide WebHook functionality. With the tcWebHooks plugin installed, you can tell TeamCity to trigger a webhook POST request as build events occur.

WebHooks are configured on a project basis, and when events occur in the build process, a POST request is submitted to the URL. You can configure as many URLs as you like (within reason) and which events will trigger the request.

There is support for proxies in this version, and webhooks are configured in the TeamCity UI. There are a few outstanding items to tidy up, but the core functionality is working.

The project is on SourceForge at tcwebhooks.sourceforge.net.





MythStatusScreenlet 0.1.1 released (theme support)

15 01 2009

I’m pleased to announce the 0.1.1 release of the MythStatusScreenlet. This release now is “theme-able”. I know Screenlets are theme-able already, but the standard theme support really just supports changing the background and other externally loaded graphics (png and svg). UPDATE: It appears I am running an old version of screenlets (0.0.14) and versions 0.1.2 and above have a lot more theme support.

In MythStatusScreenlet 0.1.1, I’ve extended (subclassed) the Screenlets utils.ini_reader to load extra options for the theme. These options control the layout and style of all the elements of the MythStatusScreenlet. As a proof of concept, I’ve quickly built a few other themes including “mythbuntu” and “glass”. I’ve renamed the default mepo theme to mepo-transparent, and created a new one for mepo that has a black background. This is because of a comment on the download page saying that a user sometimes found it hard to see the screenlet when backgrounds were changed.

Additionally, there is now support for GTK popups using the Screenlets Notifier class. The MythStatusScreenlet will popup a Notifier window when MythTV starts or finishes a recording.

I’ve tried to add mouseover tooltips too. However, I’ve found it to be quite unreliable, so it’s turned off by default.

I recently built a new MythTV machine. I installed mythbuntu 8.04 on it, which installed MythTv 0.21  Since then, my myth box no longer presents the Temperature information. I suspect a few other people might have the same problem (based on a comment on the gnome-look site), so I’ve fixed the code to only try and display the Temperature information if it is present. However, this means that I can’t easily test the Temperature display when building the themes. Please post a comment if you have this working, or have problems with it. Does anyone know if Temperature info is no longer presented in Myth 0.21, or is it a MythBuntu thing?

As usual, downloads are at gnome-look.





PHP and MySQL in Tomcat with Quercus

3 09 2008

I was recently shown Quercus which is the PHP 5 engine implemented in pure Java and hence, can run in a servlet engine like Tomcat. Caucho suggest running it in Resin but for work reasons, I needed to get it running in Tomcat.

It was very easy to get PHP working, but the MySQL integration took a bit more figuring out. All the info I could find on the web assumed you knew all about DBs in Tomcat and didn’t seem to spell it out.

So here is what I did to get it running in Tomcat 6.0

Add the required jars to tomcat’s lib directory

  1. mysql-connector-java-5.1.5-bin.jar (from mysql’s download page)
  2. quercus.jar (in the quercus zip from caucho)
  3. resin-util.jar (in the quercus zip from caucho)
  4. script-10.jar (in the quercus zip from caucho)

Add the database to tomcats context.xml file

<Context>
<Resource name="jdbc/mydatabasehandle" auth="Container"
type="javax.sql.DataSource"
username="mysql_username"
password="mysql_password"
driverClassName="com.mysql.jdbc.Driver"
maxActive="8"
url="jdbc:mysql://mysqlservername:3306/mysql_actual_database_name?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;mysqlEncoding=utf8"
maxIdle="4"/>
</Context>

Note: the jdbc url is all one line (up to mysqlEncoding=utf8) but is wrapped by the blog layout.
Note: Those really are &amp; (ampersand A-M-P semicolon). They are passed into the JDBC driver, and it must then convert html chars into text.

Add Quercus support to your web.xml

The quercus zip has an example web.xml file. These pieces below are mostly based on that.
<web-app>
<servlet>
<servlet-name>Quercus Servlet</servlet-name>
<servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
 
<!-- Tells Quercus to use the following JDBC database
and to ignore the arguments of mysqli_connect(). -->
<init-param>
<param-name>database</param-name>
<param-value>jdbc/mydatabasehandle</param-value>
</init-param>
 
<servlet-mapping>
<!-- tell tomcat about .php files -->
<servlet-name>Quercus Servlet</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>
 
<!-- tell tomcat about my php file called "myscript" (no extension)
so that URLs like /myscript/somepath will get "/somepath"
in php's $_SERVER["PATH_INFO"] variable. -->
 
<servlet-mapping>
<servlet-name>Quercus Servlet</servlet-name>
<url-pattern>/myscript/*</url-pattern>
</servlet-mapping>
 
</servlet>
</web-app>

Use mysql in your PHP code

$dbh = mysqli_connect();
if ($result = mysqli_query($dbh, $sql)){
while ($row = mysqli_fetch_object($result)){
print $row->fieldName;
}
}
mysqli_close($dbh);

Other useful bits and pieces

  • Note the use of the mysqli methods. I was not successful in getting the plain old mysql commands to work.
  • $request is the java request object, so you can do stuff like $request->getUserPrincipal() if you are doing authentication in Tomcat like I was.




Firefox 3 and Compiz Fusion animations

18 06 2008

I love Firefox 3, and have been running it on my Gutsy desktop since Beta 3. Firefox 3 now integrates into your desktop’s skin/theme really nicely, and the upshot of this is that on Linux with Compiz you get to utilise window animations within Firefox.

This sounds great, except that the AwesomeBar and search bar can end up actually being more distracting than useful. The default Gutsy animations in Compiz Fusion (and possibly in Hardy too) are “Glide 2″ for open and close animations. Firefox’s AwesomeBar and SearchBar animations use the “Utility” window type, so you can just remove Utility from “Glide 2″ and add it to another effect. I chose Fade since it was there already, and just added it to the list. Here is a screenshot to better explain it.

CompizConfig Settings Manager - Animations

Since I did’t want the gliding for open or close I added it to Fade, and removed it from Glide 2 in both the Open and Close Animation tabs.

Or, if you want to disable the AwesomeBar completely and go back to the Firefox 2 style, you can apparently set “browser.urlbar.maxRichResults” to “-1″ in Firefox’s about:config page. The comments in this post explain how to do that.





MythStatusScreenlet 0.0.3 released (Hardy support)

11 05 2008

Announcing the long awaited update to the MythStatusScreenlet to support Ubuntu Hardy Heron.

After spending quite a lot of time trying to get ElementTree working, I gave up and just rewrote the XML parsing using simple regular expressions. I know it’s a hack, but at least I have something that should work in Hardy.

# RELEASE: 0.0.3
# – No longer uses xpath, so should now work in Hardy

You can download the latest file from gnome-look. As usual, let me know if you it doesn’t work for you.





MythStatusScreenlet 0.0.2 released (MythTV 0.21 support)

24 03 2008

I’ve released a new MythStatusScreenlet. The release notes are below.

# RELEASE: 0.0.2
# – Now supports MythTV 0.20 and 0.21 xml formats
# – Better handling when backend goes away/comes back

You can download the latest file from gnome-look.





The MythStatus Screenlet is now available

7 03 2008

As mentioned on the MythStatus screenlet page, I’ve tidied up some of the code and posted a tar on the Screenlets Website.

The MythStatus Screenlet polls the XML info page of MythTV’s backend (normally port 6544), and parses the XML information to display the status of your backend. It shows the next ten upcoming recordings, highlighting in red, any that are currently recording.

It also shows Last Guide Update status, a disk space graph, Load Average and Temperature as provided by MythTV’s XML status page.





Problems converting back to the RadioTimes grabber – solved

8 01 2008

I used to use the excellent RadioTimes XML data with the XMLTV grabber to get my listings for MythTV. When the RadioTimes data was a little slow in coming over Christmas and New Year, I gave the EIT listings data a try.

The EIT data (pulling the programme listings from out of the DVB signal) mostly worked, but I think my little argos indoor aerial is not quite reliable enough. I kept getting
Started PESPacket, but !payloadStart()
Error: offset>181, pes length & current can not be queried

and then the backend would crash. I can only assume that my DVB stream is too full of errors. I hope to get a proper loft aerial sometime, but generally recordings are “good enough” (as long as it’s not too windy).

The EIT grabber had run long enough to get a weeks worth of data, so I thought I’d turn it off and wait for the RT site to come back online. A few days later the wonderful people at the RT had their side all sorted, and I was in a position to re-instate the RT grabber. However, when I went back into mythtv-setup, XMLTV was not listed as an option when setting up the source. The mythtv-setup app would just spit out errors saying Failed to run tv_find_grabbers

Since I had it running in the past, I knew it worked, but I had upgraded Fedora and MythTV since I had set up Myth, so maybe that script is missing from my machine, and I had not noticed.

I started out by re-running tv_grab_uk_rt --configure as per the Myth XMLTV page, and that did what it was supposed to do. Then I ran a test tv_grab_uk_rt --config-file ~/.mythtv/Freeview.xmltv --output /tmp/freeview.xml and it pulled down the listings correctly and dumped them into the xml file. So I ran mythfilldatabase again, and it still did nothing much. Therefore, the xmltv grabber must need to be configured in the database somewhere.

I had a look in the database, and found the following line
mysql> select * from videosource\G
*************************** 1. row ***************************
sourceid: 1
name: Freeview
xmltvgrabber: /bin/true
userid:
freqtable: default
lineupid: NULL
password: NULL
useeit: 0
1 row in set (0.00 sec)

This looked promising, so I changed it to ‘/usr/bin/tv_grab_uk_rt’ and ran mythfilldatabase. However, it would complain that I was calling the grabber wrongly and the error was something like “You may need to upgrade your xmltv grabber”.

Then I changed it to just ‘tv_grab_uk_rt’ (because reading this post hinted at the fact that it might be hardcoded to the name, not the path) and it all started working again. Yey!

Don’t forget to check that all the channels are configured with the XMLTV IDs in the channel table, by looking at the Channel Info page in MythWeb (mine had all disappeared as part of the EIT change), and that your source has a corresponding xmltv file in ~/.mythtv/<sourcename>.xmltv