Permalink
Browse files

First pass at per-project room configuration

  • Loading branch information...
1 parent 706dacd commit 426afe9bb6c639287a09e94c8f0675664aec6269 @mmrwoods mmrwoods committed Feb 1, 2011
View
3 .gitignore
@@ -1 +1,4 @@
+*.*~
+*.swp
+.project
target
View
6 README.markdown
@@ -30,7 +30,11 @@ When the build has completed, you'll have a .hpi file available which needs to b
rm -rf /var/lib/hudson/plugins/campfire*
-Then use the advanced tab of the plugin manager to upload the hpi file. Finally, restart hudson (note: not reload configuration, restart the hudson daemon).
+Then either use the advanced tab of the plugin manager to upload the hpi file or just copy it to the plugins directory, e.g.
+
+ cp campfire.hpi /var/lib/hudson/plugins/
+
+Finally, restart hudson (note: not reload configuration, restart the hudson daemon).
### Troubleshooting
View
19 src/main/java/hudson/plugins/campfire/CampfireNotifier.java
@@ -27,9 +27,16 @@
private String hudsonUrl;
private boolean smartNotify;
- /**
- * Descriptor should be singleton. (Won't this just set a class constant to an instance (but not the only possible instance) of DescriptorImpl?)
- */
+ // getter for project configuration..
+ // Configured room name should be null unless different from descriptor/global room name
+ public String getConfiguredRoomName() {
+ if ( DESCRIPTOR.getRoom().equals(room.getName()) ) {
+ return null;
+ } else {
+ return room.getName();
+ }
+ }
+
@Extension
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
@@ -119,12 +126,12 @@ private void initialize() throws IOException {
initialize(DESCRIPTOR.getSubdomain(), DESCRIPTOR.getToken(), DESCRIPTOR.getRoom(), DESCRIPTOR.getHudsonUrl(), DESCRIPTOR.getSsl(), DESCRIPTOR.getSmartNotify());
}
- private void initialize(String subdomain, String token, String room, String hudsonUrl, boolean ssl, boolean smartNotify) throws IOException {
+ private void initialize(String subdomain, String token, String roomName, String hudsonUrl, boolean ssl, boolean smartNotify) throws IOException {
campfire = new Campfire(subdomain, token, ssl);
try {
- this.room = campfire.findRoomByName(room);
+ this.room = campfire.findRoomByName(roomName);
if ( this.room == null ) {
- throw new IOException("Room '" + room + "' not found");
+ throw new IOException("Room '" + roomName + "' not found");
}
} catch (IOException e) {
throw new IOException("Cannot join room: " + e.getMessage());
View
8 src/main/java/hudson/plugins/campfire/DescriptorImpl.java
@@ -64,10 +64,14 @@ public boolean isApplicable(Class<? extends AbstractProject> aClass) {
*/
@Override
public Publisher newInstance(StaplerRequest req, JSONObject formData) throws FormException {
+ String projectRoom = req.getParameter("roomName");
+ if ( projectRoom == null || projectRoom.trim().length() == 0 ) {
+ projectRoom = room;
+ }
try {
- return new CampfireNotifier(subdomain, token, room, hudsonUrl, ssl, smartNotify);
+ return new CampfireNotifier(subdomain, token, projectRoom, hudsonUrl, ssl, smartNotify);
} catch (Exception e) {
- throw new FormException("Failed to initialize campfire notifier - check your global campfire notifier configuration settings", e, "");
+ throw new FormException("Failed to initialize campfire notifier - check your campfire notifier configuration settings", e, "");
}
}
View
17 src/main/resources/hudson/plugins/campfire/CampfireNotifier/config.jelly
@@ -3,16 +3,7 @@
This jelly script is used for per-project configuration.
See global.jelly for a general discussion about jelly script.
-->
- <!--<f:entry title="Hostname" description="Hostname of the Campfire server">-->
- <!--http://<f:textbox name="subdomain" value="${descriptor.getSubdomain()}" />.campfirenow.com-->
- <!--</f:entry>-->
- <!--<f:entry title="Token" description="The authentication token of the bot">-->
- <!--<f:password name="token" value="${descriptor.getToken()}" />-->
- <!--</f:entry>-->
- <!--<f:entry title="Room" description="Room the bot should join">-->
- <!--<f:textbox name="room" value="${descriptor.getRoom()}" />-->
- <!--</f:entry>-->
- <!--<f:entry title="SSL" description="Use SSL?">-->
- <!--<f:textbox name="ssl" value="${descriptor.getSsl()}" />-->
- <!--</f:entry>-->
-</j:jelly>
+ <f:entry title="Project Room (if different from ${descriptor.getRoom()})" help="${rootURL}/plugin/campfire/help-projectConfig-room.html">
+ <f:textbox name="roomName" value="${instance.getConfiguredRoomName()}"/>
+ </f:entry>
+</j:jelly>
View
7 src/main/webapp/help-globalConfig-room.html
@@ -1,4 +1,5 @@
<div>
- <p>Enter the name of the room to which notifications should be sent. Note that this is the name of the
- room, not the id number, e.g. "Dev Team".</p>
-</div>
+ <p>Enter the name of the room to which notifications should be sent. Note that this is the name of the
+ room, not the id number, e.g. "Dev Team". You can customize the room name per-project, but should always
+ enter a default here.</p>
+</div>
View
4 src/main/webapp/help-projectConfig-room.html
@@ -0,0 +1,4 @@
+<div>
+ <p>Enter the name of the room to which notifications should be sent. Note that this is the name of the
+ room, not the id number, e.g. "Dev Team".</p>
+</div>
View
6 src/main/webapp/help.html
@@ -1,4 +1,4 @@
<div>
- This causes Hudson to broadcast build failures and recoveries
- on a Campfire chat server.
-</div>
+ Send build notifications to a Campfire chat room.<br />
+ The campfire notifier is configured globally, but you can customize the room name per-project.
+</div>

0 comments on commit 426afe9

Please sign in to comment.