Skip to content

Commit

Permalink
Fixed incompatibility between Jabber and IRC plugin regarding configu…
Browse files Browse the repository at this point in the history
…ration parameters [JENKINS-10589]
  • Loading branch information
kutzi committed Aug 26, 2012
1 parent 44a1c88 commit 3213ccf
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 16 deletions.
17 changes: 8 additions & 9 deletions src/main/java/hudson/plugins/im/IMPublisherDescriptor.java
@@ -1,20 +1,19 @@
package hudson.plugins.im;

import hudson.plugins.im.config.ParameterNames;

import java.util.List;

public interface IMPublisherDescriptor {

static final String PREFIX = "im.";
public static final String PARAMETERNAME_STRATEGY = PREFIX + "strategy";
public static final String PARAMETERNAME_NOTIFY_START = PREFIX + "notifyStart";
public static final String PARAMETERNAME_NOTIFY_SUSPECTS = PREFIX + "notifySuspects";
public static final String PARAMETERNAME_NOTIFY_CULPRITS = PREFIX + "notifyCulprits";
public static final String PARAMETERNAME_NOTIFY_FIXERS = PREFIX + "notifyFixers";
public static final String PARAMETERNAME_NOTIFY_UPSTREAM_COMMITTERS = PREFIX + "notifyUpstreamCommitters";

public static final String PARAMETERVALUE_STRATEGY_DEFAULT = NotificationStrategy.STATECHANGE_ONLY.getDisplayName();;
public static final String[] PARAMETERVALUE_STRATEGY_VALUES = NotificationStrategy.getDisplayNames();
public static final String PARAMETERNAME_HUDSON_LOGIN = PREFIX + "hudsonLogin";

/**
* Internally used to construct the parameter names on the config page.
* @return a prefix which must be unique among all IM plugins.
*/
public ParameterNames getParamNames();

/**
* Returns <code>true</code> iff the plugin is globally enabled.
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/hudson/plugins/im/config/ParameterNames.java
@@ -0,0 +1,41 @@
package hudson.plugins.im.config;

/**
* Parameter names for the configuration pages.
*
* @author kutzi
*/
public abstract class ParameterNames {

protected abstract String getPrefix();

public String getStrategy() {
return getPrefix() + "strategy";
}

public String getNotifyStart() {
return getPrefix() + "notifyStart";
}

public String getNotifySuspects() {
return getPrefix() + "notifySuspects";
}

public String getNotifyCulprits() {
return getPrefix() + "notifyCulprits";
}

public String getNotifyFixers() {
return getPrefix() + "notifyFixers";
}
public String getNotifyUpstreamCommitters() {
return getPrefix() + "notifyUpstreamCommitters";
}

public String getJenkinsLogin() {
return getPrefix() + "jenkinsLogin";
}
}



Expand Up @@ -2,7 +2,7 @@
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">

<f:entry title="Jenkins Username" help="/plugin/instant-messaging/help-jenkins-login.html">
<f:textbox name="${descriptor.PARAMETERNAME_HUDSON_LOGIN}"
<f:textbox name="${descriptor.paramNames.jenkinsLogin}"
value="${descriptor.hudsonUserName}" />
</f:entry>

Expand Down
Expand Up @@ -6,26 +6,26 @@
</st:documentation>

<f:entry title="Notification Strategy" description="When to send notifications (all = always, failure = on any failure, failure and fixed = on failure and fixes, change = only on state change)">
<select class="setting-input" name="${descriptor.PARAMETERNAME_STRATEGY}">
<select class="setting-input" name="${descriptor.paramNames.strategy}">
<j:forEach var="value" items="${descriptor.PARAMETERVALUE_STRATEGY_VALUES}">
<f:option selected="${instance.strategy==value}">${value}</f:option>
</j:forEach>
</select>
</f:entry>
<f:entry title="Notify on build starts" description="Whether to send notifications to channels when a build starts">
<f:checkbox name="${descriptor.PARAMETERNAME_NOTIFY_START}" checked="${instance.notifyOnStart}"/>
<f:checkbox name="${descriptor.paramNames.notifyStart}" checked="${instance.notifyOnStart}"/>
</f:entry>
<f:entry title="Notify SCM committers" description="Whether to send notifications to the users that are suspected of having broken this build">
<f:checkbox name="${descriptor.PARAMETERNAME_NOTIFY_SUSPECTS}" checked="${instance.notifySuspects}"/>
<f:checkbox name="${descriptor.paramNames.notifySuspects}" checked="${instance.notifySuspects}"/>
</f:entry>
<f:entry title="Notify SCM culprits" description="Also send notifications to 'culprits' from previous unstable/failed builds">
<f:checkbox name="${descriptor.PARAMETERNAME_NOTIFY_CULPRITS}" checked="${instance.notifyCulprits}"/>
<f:checkbox name="${descriptor.paramNames.notifyCulprits}" checked="${instance.notifyCulprits}"/>
</f:entry>
<f:entry title="Notify upstream committers" description="Whether to send notifications to upstream committers if no committers were found for a broken build">
<f:checkbox name="${descriptor.PARAMETERNAME_NOTIFY_UPSTREAM_COMMITTERS}" checked="${instance.notifyUpstreamCommitters}"/>
<f:checkbox name="${descriptor.paramNames.notifyUpstreamCommitters}" checked="${instance.notifyUpstreamCommitters}"/>
</f:entry>
<f:entry title="Notify SCM fixers" description="Whether to send notifications to the users that have fixed a broken build">
<f:checkbox name="${descriptor.PARAMETERNAME_NOTIFY_FIXERS}" checked="${instance.notifyFixers}"/>
<f:checkbox name="${descriptor.paramNames.notifyFixers}" checked="${instance.notifyFixers}"/>
</f:entry>

</j:jelly>

0 comments on commit 3213ccf

Please sign in to comment.