Skip to content

Commit 196b5f1

Browse files
authored
Merge pull request #500 from rundeck/RUN-1631
RUN-1631: fix exit code for executions deletebulk --require
2 parents ca24e74 + 039ab71 commit 196b5f1

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

rd-cli-tool/src/main/java/org/rundeck/client/tool/commands/Executions.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.rundeck.client.tool.commands;
1818

19-
import com.fasterxml.jackson.databind.ObjectMapper;
2019
import lombok.Getter;
2120
import lombok.Setter;
2221
import okhttp3.ResponseBody;
@@ -48,9 +47,6 @@
4847
*/
4948
@CommandLine.Command(name = "executions", description = "List running executions, attach and follow their output, or kill them.")
5049
public class Executions extends BaseCommand {
51-
52-
private static final ObjectMapper JSON = new ObjectMapper();
53-
5450
@Getter
5551
@Setter
5652
static class KillOptions extends ExecutionIdOption{
@@ -532,7 +528,7 @@ public boolean deleteall(@CommandLine.Mixin DeleteAllExecCmd options) throws IOE
532528

533529
// End Delete all executions.
534530

535-
static interface HasJobIdList {
531+
interface HasJobIdList {
536532
List<String> getJobIdList();
537533

538534
default boolean isJobIdList() {
@@ -568,7 +564,7 @@ public boolean isIdlist() {
568564

569565
@CommandLine.Command(description = "Find and delete executions in a project. Use the query options to find and delete " +
570566
"executions, or specify executions with the `idlist` option.")
571-
public boolean deletebulk(@CommandLine.Mixin BulkDeleteCmd options,
567+
public int deletebulk(@CommandLine.Mixin BulkDeleteCmd options,
572568
@CommandLine.Mixin PagingResultOptions paging,
573569
@CommandLine.Mixin ExecutionOutputFormatOption outputFormatOption) throws IOException, InputError {
574570

@@ -588,7 +584,7 @@ public boolean deletebulk(@CommandLine.Mixin BulkDeleteCmd options,
588584
} else {
589585
getRdOutput().warning("No executions found to delete");
590586
}
591-
return !options.isRequire();
587+
return options.isRequire()?2:0;
592588
}
593589
}
594590

@@ -598,7 +594,7 @@ public boolean deletebulk(@CommandLine.Mixin BulkDeleteCmd options,
598594

599595
if (!"y".equals(s)) {
600596
getRdOutput().warning("Not deleting executions.");
601-
return false;
597+
return 1;
602598
}
603599
}
604600
final List<String> finalExecIds = execIds;
@@ -613,7 +609,7 @@ public boolean deletebulk(@CommandLine.Mixin BulkDeleteCmd options,
613609
}else{
614610
getRdOutput().info(String.format("Deleted %d executions.", result.getSuccessCount()));
615611
}
616-
return result.isAllsuccessful();
612+
return result.isAllsuccessful()?0:1;
617613
}
618614

619615
public static boolean maybeFollow(
@@ -651,7 +647,7 @@ public static boolean maybeFollow(
651647
/**
652648
* @param millis wait time
653649
*
654-
* @return wait function which returns false if interrupted, true otherwise
650+
* @return wait function which returns false if interrupted true otherwise
655651
*/
656652
private static BooleanSupplier waitUnlessInterrupt(final int millis) {
657653
return () -> {

rd-cli-tool/src/test/groovy/org/rundeck/client/tool/commands/ExecutionsSpec.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class ExecutionsSpec extends Specification {
7171

7272
where:
7373
reqd | expect
74-
true | false
75-
false | true
74+
true | 2
75+
false | 0
7676
}
7777

7878
private RdTool setupMock(RundeckApi api) {
@@ -199,7 +199,7 @@ class ExecutionsSpec extends Specification {
199199

200200
def "parse execution"() {
201201
given:
202-
MockWebServer server = new MockWebServer();
202+
MockWebServer server = new MockWebServer()
203203
server.enqueue(new MockResponse().setBody('''{
204204
"id": 5418,
205205
"href": "http://ecto1.local:4440/api/19/execution/5418",
@@ -233,7 +233,7 @@ class ExecutionsSpec extends Specification {
233233
]
234234
}'''
235235
).addHeader('content-type', 'application/json')
236-
);
236+
)
237237
server.start()
238238

239239
def retrofit = new Retrofit.Builder().baseUrl(server.url('/api/19/')).
@@ -256,7 +256,7 @@ class ExecutionsSpec extends Specification {
256256

257257
def "parse compacted log"() {
258258
given:
259-
MockWebServer server = new MockWebServer();
259+
MockWebServer server = new MockWebServer()
260260
server.enqueue(new MockResponse().setBody('''{
261261
"id": 5418,
262262
"compacted":true,
@@ -269,7 +269,7 @@ class ExecutionsSpec extends Specification {
269269
"serverUUID": "3425B691-7319-4EEE-8425-F053C628B4BA"
270270
}'''
271271
).addHeader('content-type', 'application/json')
272-
);
272+
)
273273
server.start()
274274

275275
def retrofit = new Retrofit.Builder().baseUrl(server.url('/api/19/')).

0 commit comments

Comments
 (0)