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:
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:
Looking at other plugins, they use the following structure, so I've tried that as well.
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?
The website describes it as being easy (yeah, if it works):
1. Shut down TeamCity server.
2. Copy the zip archive with the plugin to <TeamCity Data Directory>/plugins.
3. Start the TeamCity server: the plugin files will be unpacked and processed automatically.
There is also online step-by-step guide on installing TeamCity plugin here.
You need to use the following code:
Loggers.SERVER.info("Your message");
This will log to teamcity-server.log. Loggers class also contain other static fields like AUTH, VCS and so on. Each corresponds to separate log file (e.g. teamcity-vcs.log, teamcity-auth.log, etc.). In order to use this code you also need to add the following dependency in your pom.xml (for Maven):
<dependency>
<groupId>com.intellij</groupId>
<artifactId>openapi</artifactId>
<version>7.0.3</version>
<scope>provided</scope>
</dependency>
This was tested with Teamcity 8.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With