Skip to content
Permalink
Browse files

[JENKINS-28041] Incorporated changes from feedback by Oleg

  • Loading branch information
pjanouse committed May 18, 2015
1 parent 3cc5162 commit 9d284a5e5f225d3465bfefd9c5946e4c48f7fa38
@@ -51,15 +51,21 @@ public String getShortDescription() {
protected int run() throws Exception {

boolean errorOccurred = false;
final Jenkins jenkins = Jenkins.getInstance();

HashSet<String> hs = new HashSet<String>();
if (jenkins == null) {
stderr.println("The Jenkins instance has not been started, or was already shut down!");
return -1;
}

final HashSet<String> hs = new HashSet<String>();
hs.addAll(jobs);

for (String job_s: hs) {
AbstractItem job = null;

try {
job = (AbstractItem) Jenkins.getInstance().getItemByFullName(job_s);
job = (AbstractItem) jenkins.getItemByFullName(job_s);

if(job == null) {
stderr.format("No such job '%s'\n", job_s);
@@ -52,15 +52,21 @@ public String getShortDescription() {
protected int run() throws Exception {

boolean errorOccurred = false;
final Jenkins jenkins = Jenkins.getInstance();

HashSet<String> hs = new HashSet<String>();
if (jenkins == null) {
stderr.println("The Jenkins instance has not been started, or was already shut down!");
return -1;
}

final HashSet<String> hs = new HashSet<String>();
hs.addAll(nodes);

for (String node_s : hs) {
Node node = null;

try {
node = Jenkins.getInstance().getNode(node_s);
node = jenkins.getNode(node_s);

if(node == null) {
stderr.format("No such node '%s'\n", node_s);
@@ -76,7 +82,7 @@ protected int run() throws Exception {
continue;
}

Jenkins.getInstance().removeNode(node);
jenkins.removeNode(node);
} catch (Exception e) {
stderr.format("Unexpected exception occurred during deletion of node '%s': %s\n",
node == null ? "(null)" : node.toComputer().getName(),
@@ -55,7 +55,7 @@ protected int run() throws Exception {
boolean errorOccurred = false;

// Remove duplicates
HashSet<String> hs = new HashSet<String>();
final HashSet<String> hs = new HashSet<String>();
hs.addAll(views);

ViewOptionHandler voh = new ViewOptionHandler(null, null, null);
@@ -38,6 +38,8 @@
import org.kohsuke.args4j.spi.Parameters;
import org.kohsuke.args4j.spi.Setter;

import javax.annotation.CheckForNull;

/**
* Refers to {@link View} by its name.
*
@@ -73,10 +75,25 @@ public int parseArguments(Parameters params) throws CmdLineException {
return 1;
}

public View getView(String name) throws CmdLineException {
/**
*
* Gets a view by its name
*
* @param name A view name
* @return The {@link View} instance. Null if {@link Jenkins#getInstance()} returns null.
* @throws CmdLineException
* If view isn't found or an un-expected error occurred
* @since TODO
*/
@CheckForNull
public View getView(final String name) throws CmdLineException {

View view = null;
ViewGroup group = Jenkins.getInstance();
View view = null;

if (group == null)
throw new CmdLineException(owner,
"The Jenkins instance has not been started, or was already shut down!");

final StringTokenizer tok = new StringTokenizer(name, "/");
while(tok.hasMoreTokens()) {
@@ -45,7 +45,7 @@
import org.jvnet.hudson.test.JenkinsRule;

/**
* @author ??, pjanouse
* @author ogondza, pjanouse
*/
public class DeleteViewCommandTest {

0 comments on commit 9d284a5

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