Adding Jersey support to an existing plugin

Hi. I am the author of the tcWebHooks plugin which provides outbound Webhooks support for TeamCity.

I've had a number of requests to provide a REST API for my plugin and would like to move to utilising the same API for my plugin UI (eg, JQuery calling Jersey).

Is there an easy way to add Jersey to a plugin? I've looked at the TeamCity REST API plugin source, but it seems like a lot of code to just get Jersey working.
I also looked at extending the plugin, but it's not very MAVEN friendly and would take a lot to fit into my existing plugin structure.

Is there a simple HelloWorld Jersey in TeamCity project somewhere?

Or is there an extension point in TeamCity that is not the full Spring MVC one that would allow Jersey integration?

Many thanks in advance, Net Wolf.

2 comments
Comment actions Permalink

I have made good progress by copying the CCTray contrib plugin and now have a simple HelloWorld REST request object extending the REST API.
I am using TeamCity 9

I have had a number of misleading errors however. I have learnt the following:

  1. Despite the documentation saying you need to provide all libraries, if you set use-separate-classloader="true" they will be inherited if you have a plugin dependency.
    I was trying to load the libraries into my jar and it was failing to do the spring registration.
  2. You can't have a plugin dependency if you don't enable the seperate classloader.
  3. You can have multiple jars in a plugin each with their own build-server-plugin-XXXXX.xml file. For a while I thought that was the cause of my spring beans not registering.
  4. The REST url binding parameters are not required despite the errors in the teamcity log complaining that it was missing. I think this was related to not having the plugin dependency working correctly, which was in turn caused by not using the seperate classloader.


I'll push my code to github later today or tomorrow.

0
Comment actions Permalink

This commit has a working plugin which supports standard teamcity spring mvc with jsp and a Jersey REST endpoint.

https://github.com/tcplugins/tcWebHooks/commit/64ad147cb80993e2727af7db294a3c7429330c83

The jersey part just does hello world, when hitting the following URI: teamcity_server/app/rest/webhooks/hello

0

Please sign in to leave a comment.