From 5aecea02b6efa324cf96c4e93c6d4c28c9788e57 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Thu, 7 Feb 2019 09:08:31 +0100 Subject: [PATCH] control flow: Replace if with case --- src/com/sap/piper/cm/ChangeManagement.groovy | 58 +++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/com/sap/piper/cm/ChangeManagement.groovy b/src/com/sap/piper/cm/ChangeManagement.groovy index ec48efa0f..b8f788a13 100644 --- a/src/com/sap/piper/cm/ChangeManagement.groovy +++ b/src/com/sap/piper/cm/ChangeManagement.groovy @@ -256,41 +256,47 @@ public class ChangeManagement implements Serializable { else shArgs.put('returnStatus', true) - if(type == BackendType.RFC) { + def result = 1 - shArgs.script = command + switch(type) { - args = args.plus([ - "--env ABAP_DEVELOPMENT_SERVER=${endpoint}", - "--env ABAP_DEVELOPMENT_USER=${script.username}", - "--env ABAP_DEVELOPMENT_PASSWORD=${script.password}"]) + case BackendType.RFC: - dockerOptions = dockerOptions.plus(args) + shArgs.script = command - def result = 1 + args = args.plus([ + "--env ABAP_DEVELOPMENT_SERVER=${endpoint}", + "--env ABAP_DEVELOPMENT_USER=${script.username}", + "--env ABAP_DEVELOPMENT_PASSWORD=${script.password}"]) - script.dockerExecute(script: script, - dockerImage: dockerImage, - dockerOptions: dockerOptions ) { + dockerOptions = dockerOptions.plus(args) + + script.dockerExecute(script: script, + dockerImage: dockerImage, + dockerOptions: dockerOptions ) { + + result = script.sh(shArgs) + + } + + break + + case BackendType.SOLMAN: + case BackendType.CTS: + + shArgs.script = getCMCommandLine(type, endpoint, script.username, script.password, + command, args, + clientOpts) + + // user and password are masked by withCredentials + script.echo """[INFO] Executing command line: "${shArgs.script}".""" result = script.sh(shArgs) - } - - return result - - } else { - - def cmScript = getCMCommandLine(type, endpoint, script.username, script.password, - command, args, - clientOpts) - - shArgs.script = cmScript - - // user and password are masked by withCredentials - script.echo """[INFO] Executing command line: "${cmScript}".""" - return script.sh(shArgs) + break } + + return result } }