diff --git a/core/src/main/java/hudson/cli/ListJobsCommand.java b/core/src/main/java/hudson/cli/ListJobsCommand.java index cdce9d6b46..af858d3f04 100644 --- a/core/src/main/java/hudson/cli/ListJobsCommand.java +++ b/core/src/main/java/hudson/cli/ListJobsCommand.java @@ -75,7 +75,7 @@ public class ListJobsCommand extends CLICommand { // No view and no item group with the given name found. else { stderr.println("No view or item group with the given name found"); - jobs = Collections.emptyList(); + return -1; } } } diff --git a/core/src/test/java/hudson/cli/ListJobsCommandTest.java b/core/src/test/java/hudson/cli/ListJobsCommandTest.java index f264777ed5..7522bc8695 100644 --- a/core/src/test/java/hudson/cli/ListJobsCommandTest.java +++ b/core/src/test/java/hudson/cli/ListJobsCommandTest.java @@ -58,8 +58,7 @@ public class ListJobsCommandTest { when(jenkins.getView(null)).thenReturn(null); when(jenkins.getItemByFullName(null)).thenReturn(null); - // TODO: One would expect -1 here - assertThat(runWith("NoSuchViewOrItemGroup"), equalTo(0)); + assertThat(runWith("NoSuchViewOrItemGroup"), equalTo(-1)); assertThat(stdout, is(empty())); assertThat(stderr, is(not(empty()))); }