Problem getting BuildServerAdapter plugin working

Hello,

I am trying to create a plugin that extends BuildServerAdapter, just like the provided sample code for the logging listener.

My code looks like this:
public class TeamCityX10Listener extends BuildServerAdapter {


    private static final Logger log = Logger.getInstance(TeamCityX10Listener.class.getName());

    private CM17ASerialController controller;
    private final SBuildServer myBuildServer;


    public TeamCityX10Listener(SBuildServer sBuildServer) {

        this.myBuildServer = sBuildServer;
    }


    public void register(){
        System.out.println("Registering TeamCityX10Listener");
        myBuildServer.addListener(this);
    }


    private void sendCommand(byte command) {
          //sends X10 command, code removed
    }


// bunch of code removed

    public void buildStarted(SRunningBuild sRunningBuild) {
        System.out.println("Sending buildStarted message");
        sendCommand(Command.ON);
    }


// bunch of code removed
}

The code is packaged into a zip file with the structure:
X10Notifier.zip
  -> server
          comm.jar (support jar file)
          x10.jar (support jar file)
          x10Notifier.jar
  teamcity-plugin.xml

I put this file into my TeamCity data directory and when I start the TeamCity Web Server service, it gets unpacked into /plugins/.unpacked and looking in the TeamCity server log file, I can see that the plugin is correctly registered.

However, when I run a build, nothing happens! I know that this code works, but I do not know why the plugin doesnt seem to be working. I was able to get this code running when I was extending the Notifer class, like tcGrowl does, the X10 commands worked with no problems when a build was run.

When the plugin is set up as a BuildServerAdapter, as I think it should be (because this is not a per user notification that I want), nothing appears to be running. I have some System.out.println statements in the classes methods so I could at least check if the plugin is being registered or if the events in the class are firing, but nothing is being written anywhere.

Please help,
Jeff

4 comments
Comment actions Permalink

So you see message "Registering TeamCityX10Listener" in the log but do not see message "Sending buildStarted message" when build starts? That's strange. Is it possible that your server starts with outdated version of your plugin? Could you please prepare a zip archive of your plugin with source code so that we can try to reproduce this bug?


--
Pavel Sher

0
Comment actions Permalink

I have attached the zip containing my project. I'm guessing my problem is more configuration that code related, but I cannot figure out what is going on.

Thanks,
Jeff



Attachment(s):
X10Notifier.zip
0
Comment actions Permalink

Please try to modify bean registration in your spring config:
    <bean id="x10Listener" init-method="register"/>

At least I did not find who calls register() method.

--
Pavel Sher

0
Comment actions Permalink

Hi Pavel,

The did the trick. In the samplePlugin.zip file, in META-INF/build-server-plugin-samplePlugin.xml file, the init-method attribute is missing from the following example:
<bean id="sampleListener" />

That should probably be updated to include init-method.

Thanks for all the help,
Jeff

0

Please sign in to leave a comment.