Notificator Plugin not running Follow
I'm sorry that this post is going to be a bit open-ended, but I'm not sure where to go from here. I'm trying to make a Campfire plugin for TeamCity. I initially wrote my own from scratch but after no luck, I modified my sources to use some of the code from: https://github.com/radamant/Team-City-Campfire-Notifier-Plugin.
The code builds fine, the web server shows that the plugin has been found, but nothing happens. I look in the logs for the log messages that my code produces and they aren't there which leads me to believe my plugin is never called. I don't see any values to fill in under "My Settings and Tools" either. I thought maybe I needed some jsp pages, but it doesn't look like other Notificator plugins require them. I'm not sure what I'm missing and am about out of guesses.
Info:
I'm using Eclipse Indigo to build the jar.
I've attached the zipped plugin.
Any help/pointers would be appreaciated!
Attachment(s):
CampfirePlugin.zip
Please sign in to leave a comment.
build-server-plugin-campfire.xml:
<?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="CampfirePlugin" />
</beans>
CampfirePlugin.java
package com.SDS;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
import jetbrains.buildServer.Build;
import jetbrains.buildServer.log.Loggers;
import jetbrains.buildServer.notification.*;
import jetbrains.buildServer.responsibility.ResponsibilityEntry;
import jetbrains.buildServer.responsibility.TestNameResponsibilityEntry;
import jetbrains.buildServer.serverSide.*;
import jetbrains.buildServer.serverSide.mute.MuteInfo;
import jetbrains.buildServer.tests.TestName;
import jetbrains.buildServer.users.*;
import jetbrains.buildServer.vcs.SelectPrevBuildPolicy;
import jetbrains.buildServer.vcs.VcsRoot;
public class CampfirePlugin implements Notificator {
private static final String TYPE = "campfireNotifier";
private static final String TYPE_NAME = "Campfire Notifier";
private static final String CAMPFIRE_ROOM_NUMBER = "campfireRoomNumber";
private static final String CAMPFIRE_AUTH_TOKEN = "campfireAuthToken";
private static final String CAMPFIRE_URL = "campfireUrl";
private static final String CAMPFIRE_USE_SSL = "campfireUseSsl";
public CampfirePlugin(NotificatorRegistry notificatorRegistry)
throws IOException {
Loggers.SERVER.info("Campfire Constructor");
ArrayList<UserPropertyInfo> userProps = new ArrayList<UserPropertyInfo>();
userProps.add(new UserPropertyInfo(CAMPFIRE_AUTH_TOKEN, "Auth Token"));
userProps.add(new UserPropertyInfo(CAMPFIRE_URL, "Campfire Url"));
userProps.add(new UserPropertyInfo(CAMPFIRE_USE_SSL, "Use SSL (Y or N)"));
userProps.add(new UserPropertyInfo(CAMPFIRE_ROOM_NUMBER, "Room Id"));
notificatorRegistry.register(this, userProps);
}
public void doNotifications(SUser user, String message) {
Loggers.SERVER.info("Campfire doNotifications");
String authToken = user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_AUTH_TOKEN));
String url = user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_URL));
Boolean useSsl = user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_USE_SSL)).trim().equalsIgnoreCase("y");
String roomNumber = user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_ROOM_NUMBER));
CampfireConnection campfire = new CampfireConnection(authToken, url, useSsl);
for (String message : messages)
campfire.postMessage(roomNumber, message);
}
@Override
public void notifyBuildSuccessful(SRunningBuild sRunningBuild,
Set<SUser> sUsers) {
// Send to Campfire
for (SUser user : sUsers) {
doNotifications(user, "test");
}
}
@NotNull
public String getNotificatorType() {
return TYPE; //To change body of implemented methods use File | Settings | File Templates.
}
@NotNull
public String getDisplayName() {
return TYPE_NAME; //To change body of implemented methods use File | Settings | File Templates.
}
... other notification overrides
}
Hi Eric,
My guess is that your plugin was built against pretty old API jar.
Could you please check the versions of the API and the system you start with. Unfortunately the notifications API is changing quite often (in 6.5 as well).
And in order to make your plugin more robust I'd suggest you not to implement "Notificator" interface, but extend from "NotificatorAdapter". It will also simplify your code a little.
--
Thanks you,
Maxim
Eric,
There is one more idea: please put your build-server-plugin-campfire.xml inside META-INF directory.
The plugin worked for me when I did it (see attachment).
---
Maxim
Attachment(s):
My Settings & Tools > General -- TeamCity_1317034378772.png
Maxim,
Thank you for your help. I tried putting just the JAR file into the web-inf/lib directory and it loaded, so I must have been building the plugin wrong. Also, I will check out the NotificatorAdapter, thanks for the tip!
Any chance you'll release your plugin when you're "done"? ;)
I am running the same code as radamant made for the Campfire Plugin, just modified the build-failed and build-successful messages to meet our business needs. You can find his code at https://github.com/radamant/Team-City-Campfire-Notifier-Plugin
Thanks. I found his code the other day, but I was hoping to avoid having to setup a Java environment just to build this plugin :S
Tried to just use the one you added to the first post here, but it fails with "java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials" :(
Gotcha, I'm pretty busy in the office today but I'll get my jar's together and write up a quick thing to get my plugin working from start to finish this weekend.
Awesome, it's much appreciated!
I posted my built app, for those that don't feel like setting up the environment. I found the build environment and knowing where to put things is by far the hardest part of setting up a plugin. I know I'm still not doing it the exact way that it was intended, but it seems to work fine right now.
On a side note, make sure you save the JAR files. I think, since I place them in a directory that they aren't meant to be in as a plugin, they may get wiped when upgrading versions.
The ZIP includes a folder of JAR files to use, as well as a PDF which (I hope) is a straight-forward walkthrough on how to get the plugin working. Please let me know if there are any problems or something isn't clear.
Attachment(s):
CampfirePlugin.zip
Nice, I'll give it a shot this weekend. Thanks
Gave it a try now, but it looks like I'm missing something on our build server. I keep getting "java.lang.NoClassDefFoundError: org/apache/http/auth/Credentials at com.SDS.CampfirePlugin.doNotifications(CampfirePlugin.java:49)" when it tries to post a message.
I only have the JRE installed on the build server. Do I need the JDK instead? Something else missing?
No I don't think you should need anything else. I did say to make sure none of the JAR files overwrote the original library files, but you should make sure that the Campfire one does overwrite the original. It looks like it is running an old copy of the Campfire plugin, because I no longer use a class called "CampfirePlugin.java".
Got it working now :)
It was just a matter of RTFM. I took the archive and copied the whole thing to the plugins folder instead putting just the jar files in the lib folder.
Thanks again, btw