Debugging plugins


I want to know the best way to debug a plugin for Teamcity. My current approach is to run mvn package, upload the zip file to Teamcity and then restart the server. This takes too much time. I've read I can pass this parameter to the JVM "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5555" but I don't understand how can I debug a plugin if its not compiled by maven and then uploaded to the server? 

If I create a breakpoint in my java code locally, how does the Teamcity instance know it should use this new code with the breakpoint? 

It would be very helpful to see a video about this or a detailed guide. I cannot find this question properly answered anywhere. 



1 comment
Comment actions Permalink

I use maven and Eclipse, but I presume it's the same in intelliJ. Running the above settings tells Java to allow a TCP connection to interact with the JVM in debug mode.

Then you configure your IDE to connect to that port with a debug session. I've not done it with intelliJ, but this page looks useful.

You can set breakpoints locally and the server will break there, and you can step through code, inspect most variables and even call some methods from within your IDE. When the code is re-compiled locally in your IDE, the bytecode is also hot swapped into the JVM via the remote connection.

Simple changes to your class logic can be swapped in, but changes that result in a class or method signature change (eg, add a new method, change method arguments) will need a full compile and redeploy.

If I need to do a maven compile, I run it locally in my IDE and then copy (scp since I am using Linux) the new zip file to the server plugin directory, and then choose restart from the diagnostics tab in teamcity's admin section. Once it's up and running again, reconnect your debug session and carry on.

I wrote this post in 2009, which may be of some use on how I setup teamcity to support remote debugging, and the commands below are used to update JSPs. TeamCity will recompile them when in development mode.

rsync -azlpv ~/git/tcWebHooks/tcwebhooks-web-ui/src/main/resources/buildServerResources/WebHook/* teamcity:/opt/TeamCity/webapps/ROOT/plugins/tcWebHooks/WebHook/.
rsync -azlpv ~/git/tcWebHooks/tcwebhooks-rest-api/src/main/resources/buildServerResources/WebHookRestApi/* teamcity:/opt/TeamCity/webapps/ROOT/plugins/tcWebHooks-rest-api/WebHookRestApi/.

Please sign in to leave a comment.