mirror of
https://github.com/jenkinsci/mattermost-plugin.git
synced 2024-11-18 16:21:43 +02:00
Avoid duplicated completed notification
Additionally remove introduced "and counting" suffix in completed notification Follow up of https://github.com/jenkinsci/mattermost-plugin/pull/13
This commit is contained in:
parent
76c645063f
commit
87653537f0
@ -371,7 +371,12 @@ public class ActiveNotifier implements FineGrainedNotifier {
|
||||
if (message.toString().contains(BACK_TO_NORMAL_STATUS_MESSAGE)) {
|
||||
durationString = createBackToNormalDurationString();
|
||||
} else {
|
||||
durationString = build.getDurationString();
|
||||
long duration = build.getDuration();
|
||||
if (duration == 0L) {
|
||||
durationString = Util.getTimeSpanString(System.currentTimeMillis() - build.getStartTimeInMillis());
|
||||
} else {
|
||||
durationString = Util.getTimeSpanString(build.getDuration());
|
||||
}
|
||||
}
|
||||
message.append(durationString);
|
||||
return this;
|
||||
|
@ -1,58 +0,0 @@
|
||||
package jenkins.plugins.mattermost;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.model.AbstractBuild;
|
||||
import hudson.model.AbstractProject;
|
||||
import hudson.model.BuildListener;
|
||||
import hudson.model.Descriptor;
|
||||
import hudson.model.TaskListener;
|
||||
import hudson.model.listeners.RunListener;
|
||||
import hudson.tasks.Publisher;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Extension
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class MattermostListener extends RunListener<AbstractBuild> {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MattermostListener.class.getName());
|
||||
|
||||
public MattermostListener() {
|
||||
super(AbstractBuild.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleted(AbstractBuild r, TaskListener listener) {
|
||||
getNotifier(r.getProject(), listener).completed(r);
|
||||
super.onCompleted(r, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStarted(AbstractBuild r, TaskListener listener) {
|
||||
// getNotifier(r.getProject()).started(r);
|
||||
// super.onStarted(r, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleted(AbstractBuild r) {
|
||||
// getNotifier(r.getProject()).deleted(r);
|
||||
// super.onDeleted(r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinalized(AbstractBuild r) {
|
||||
// getNotifier(r.getProject()).finalized(r);
|
||||
// super.onFinalized(r);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
FineGrainedNotifier getNotifier(AbstractProject project, TaskListener listener) {
|
||||
Map<Descriptor<Publisher>, Publisher> map = project.getPublishersList().toMap();
|
||||
for (Publisher publisher : map.values()) {
|
||||
if (publisher instanceof MattermostNotifier) {
|
||||
return new ActiveNotifier((MattermostNotifier) publisher, (BuildListener) listener, new JenkinsTokenExpander(listener));
|
||||
}
|
||||
}
|
||||
return new DisabledNotifier();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user