Skip to content
Permalink
Browse files

Use FullDisplayName for 'cb' command, too, if available [JENKINS-6560]

  • Loading branch information...
kutzi committed Jan 6, 2015
1 parent f08b787 commit 4ca5e97cfdd01ab23e7301f66cfa3471f8a17d3e
Showing with 14 additions and 5 deletions.
  1. +14 −5 src/main/java/hudson/plugins/im/bot/CurrentlyBuildingCommand.java
@@ -2,10 +2,12 @@

import hudson.Extension;
import hudson.Util;
import hudson.model.Item;
import hudson.model.Computer;
import hudson.model.Executor;
import hudson.model.Hudson;
import hudson.model.Queue.Executable;
import hudson.model.queue.SubTask;
import hudson.plugins.im.IMChat;
import hudson.plugins.im.IMException;
import hudson.plugins.im.IMMessage;
@@ -14,6 +16,8 @@
import java.util.Arrays;
import java.util.Collection;

import jenkins.model.Jenkins;

/**
* CurrentlyBuilding command for instant messaging plugin.
*
@@ -24,8 +28,6 @@
@Extension
public class CurrentlyBuildingCommand extends BotCommand {

private static final String HELP_MESSAGE = " - list jobs which are currently in progress";

@Override
public Collection<String> getCommandNames() {
return Arrays.asList("currentlyBuilding", "cb");
@@ -37,17 +39,24 @@ public void executeCommand(Bot bot, IMChat chat, IMMessage message,
StringBuffer msg = new StringBuffer();
msg.append("Currently building:");
boolean currentlyJobsInProgess = false;
for (Computer computer : Hudson.getInstance().getComputers()) {
for (Computer computer : Jenkins.getInstance().getComputers()) {
for (Executor executor : computer.getExecutors()) {
Executable currentExecutable = executor.getCurrentExecutable();
if (currentExecutable != null) {
currentlyJobsInProgess = true;

SubTask task = currentExecutable.getParent();
Item item = null;
if (task instanceof Item) {
item = (Item) task;
}

msg.append("\n- ");
msg.append(computer.getDisplayName());
msg.append("#");
msg.append(executor.getNumber());
msg.append(": ");
msg.append(currentExecutable.getParent().getDisplayName());
msg.append(item != null ? item.getFullDisplayName() : task.getDisplayName());
msg.append(" (Elapsed time: ");
msg.append(Util.getTimeSpanString(executor.getElapsedTime()));
msg.append(", Estimated remaining time: ");
@@ -66,7 +75,7 @@ public void executeCommand(Bot bot, IMChat chat, IMMessage message,

@Override
public String getHelp() {
return HELP_MESSAGE;
return " - list jobs which are currently in progress";
}

}

0 comments on commit 4ca5e97

Please sign in to comment.
You can’t perform that action at this time.