From 1ef9cae2dea05eb358c3abab59ac4fa60f5fd257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Gond=C5=BEa?= Date: Sun, 16 Jun 2013 11:14:29 +0200 Subject: [PATCH] [FIXED JENKINS-18367] Use non-zero return code in case list-jobs CLI command fails --- core/src/main/java/hudson/cli/ListJobsCommand.java | 2 +- core/src/test/java/hudson/cli/ListJobsCommandTest.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) 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()))); }