I am playing around with a TeamCity install and developing a plugin that extends a BuildServerAdapter. When I package it up and install it to the server, teamcity-server.log contains entries for my plugin:
- found when scanning the plugins (.BuildServer\plugins) folder
- registering agent plugin from server plugin
- loads in the shared classloader
- is loaded
The plugin is also listed on the plugins page in the server administration.
Beyond that...nothing. I've put in various log statements, via both the logger and System.out, and I don't see them. I've even added an exception into the constructor, and I see no evidence of that either in the system logs. When a build happens, there's again no evidence that my code is called.
public class CustomBuildServerAdapter extends BuildServerAdapter {
private SBuildServer myBuildServer;
private static final Logger LOG = Logger.getLogger(CustomBuildServerAdapter.class);
private void debug(String msg) { LOG.debug(msg); System.out.println(msg); }
public CustomBuildServerAdapter(SBuildServer aBuildServer) throws Exception {
throw new Exception("constructor is being called, at least we know that...");
//myBuildServer = aBuildServer;
//debug("constructor");
}
public void register() {
debug("registering");
myBuildServer.addListener(this);
debug("registered");
}
public void buildFinished(SRunningBuild build) {
debug("build finished");
postMessage(build.getFullName() + " - " + build.getStatusDescriptor().getText());
debug("message posted");
}
...
The zip that I copy to .BuildServer\plugins
has the following structure:
- MyTeamCityPlugin.zip
- teamcity.plugin.xml
- server
- MyTeamCityPlugin.jar
- package folders containing class files
- META-INF
- build-server-plugin.xml
- MANIFEST.MF
Looking at other plugins, they use the following structure, so I've tried that as well.
- MyTeamCityPlugin.zip
- MyTeamCityPlugin
- teamcity.plugin.xml
- MyTeamCityPlugin.jar
- package folders containing class files
- META-INF
- build-server-plugin.xml
- MANIFEST.MF
- MyTeamCityPlugin
My build-server-plugin.xml contains the following:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="constructor">
<bean id="myplugin" class="com.blah.blah.blah.CustomBuildServerAdapter" init-method="register"/>
</beans>
I'm part of the way there since the teamcity-server.log does indicate it knows about the plugin, and no longer throws an exception trying to load it. Unfortunately, not erring isn't the same working.
Using the ant build scripts from the sample plugin, I get the following error, so I've been packing things manually. This results in the seemingly successful load per above.
Failed to initialize spring context for plugin MyTeamCityPlugin. Error creating bean with name 'simpleRunnerRunType': instantiation of bean failed.
Can anyone give me the kick I need to get this running correctly?