From a24c89ce129b046dfd8647c0cfc1720712933442 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 17 May 2019 14:52:27 +0200 Subject: [PATCH] fix code climate issues --- .../init.groovy.d/resolvePlugins.groovy | 2 +- resolvePlugins.groovy | 21 ++++++++-------- resolvePlugins.sh | 24 +++++++++---------- steps.groovy | 10 +++++--- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/jenkins_home_init/init.groovy.d/resolvePlugins.groovy b/jenkins_home_init/init.groovy.d/resolvePlugins.groovy index d38f82201..de5ad3086 100644 --- a/jenkins_home_init/init.groovy.d/resolvePlugins.groovy +++ b/jenkins_home_init/init.groovy.d/resolvePlugins.groovy @@ -39,7 +39,7 @@ def resolvePlugin(call) { for(def pd in pDescs) { if(pd.getSymbol() == call) - return pd.real.plugin?.shortName + return pd.real.plugin?.shortName } return null } diff --git a/resolvePlugins.groovy b/resolvePlugins.groovy index d3a6538da..5f0468037 100644 --- a/resolvePlugins.groovy +++ b/resolvePlugins.groovy @@ -7,15 +7,15 @@ def stepPluginMapping = [:] println "[INFO] Resolving plugins ..." for(def step in stepCallMapping) { - def resolvedPlugins = [:] - for(def call in step.value) { - def resolvedPlugin = resolvePlugin(call) - if (! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED' - if(resolvedPlugins[resolvedPlugin] == null) - resolvedPlugins[resolvedPlugin] = (Set)[] - resolvedPlugins[resolvedPlugin] << call - stepPluginMapping.put(step.key,resolvedPlugins) - } + def resolvedPlugins = [:] + for(def call in step.value) { + def resolvedPlugin = resolvePlugin(call) + if (! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED' + if(resolvedPlugins[resolvedPlugin] == null) + resolvedPlugins[resolvedPlugin] = (Set)[] + resolvedPlugins[resolvedPlugin] << call + stepPluginMapping.put(step.key,resolvedPlugins) + } } def result = System.getenv()['result'] @@ -35,8 +35,7 @@ def resolvePlugin(call) { for(def pd in pDescs) { if(pd.getSymbol() == call) - return pd.real.plugin?.shortName + return pd.real.plugin?.shortName } return null } - diff --git a/resolvePlugins.sh b/resolvePlugins.sh index 37a108ee5..2a328c273 100755 --- a/resolvePlugins.sh +++ b/resolvePlugins.sh @@ -5,26 +5,26 @@ groovy steps.groovy [ -d jenkins_home ] && rm -rf jenkins_home - cp -r jenkins_home_init jenkins_home +cp -r jenkins_home_init jenkins_home -CALLS="`pwd`/jenkins_home/piper/calls.json" +CALLS="$(pwd)/jenkins_home/piper/calls.json" -mkdir -p `dirname ${CALLS}` +mkdir -p $(dirname "${CALLS}") -mv target/performedCalls.json ${CALLS} +mv target/performedCalls.json "${CALLS}" -[ -f ${CALLS} ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; } +[ -f "${CALLS}" ] || { echo "File \"${CALLS}\" does not exist." ; exit 1; } -cID=$(docker run -d -v `pwd`/jenkins_home:/var/jenkins_home --env calls=/var/jenkins_home/piper/calls.json --env result=/var/jenkins_home/piper/result.json ppiper/jenkins-master); -echo "ContainerId: ${cID}"; +cID="$(docker run -d -v `pwd`/jenkins_home:/var/jenkins_home --env calls=/var/jenkins_home/piper/calls.json --env result=/var/jenkins_home/piper/result.json ppiper/jenkins-master)" +echo "ContainerId: ${cID}" while true do - [ -f jenkins_home/piper/result.json ] && { docker rm -f ${cID}; break; } # normal ... - [ -f jenkins_home/piper/FAILURE ] && { docker rm -f ${cID}; break; } # executing of our init script failed - docker ps --no-trunc |grep -q ${cID} || break # docker container does not run anymore + [ -f jenkins_home/piper/result.json ] && { docker rm -f "${cID}"; break; } # normal ... + [ -f jenkins_home/piper/FAILURE ] && { docker rm -f "${cID}"; break; } # executing of our init script failed + docker ps --no-trunc |grep -q "${cID}"|| break # docker container does not run anymore echo "[INFO] waiting for results" sleep 10 done -RESULT="`pwd`/jenkins_home/piper/result.json" -[ -f ${RESULT} ] && cat jenkins_home/piper/result.json +RESULT="$(pwd)/jenkins_home/piper/result.json" +[ -f "${RESULT}" ] && cat jenkins_home/piper/result.json diff --git a/steps.groovy b/steps.groovy index ab25b6fd7..8a6efd4b4 100644 --- a/steps.groovy +++ b/steps.groovy @@ -18,7 +18,7 @@ _calls = null // Remove selfs calls.each { c -> c.value.remove(c.key) -} +} int counter=0 @@ -42,7 +42,11 @@ while(counter < 1600) { for (def calledStep in calledSteps) { - if (calledStep in Map) { + if(calledStep in Map) { + // After some time not working on this I have acually forgotten + // what needs to be done here ... In order not to forget that + // here is maybe something missing we emit a log message. + System.err << "[DEBUG] This is not handled yet.(${calledStep})\n" } else { if(calledStep in piperSteps) { toBeReplaced = calledStep @@ -50,7 +54,7 @@ while(counter < 1600) { break } } - } + } if(toBeReplaced) { def replacement = [:] replacement[toBeReplaced] = calls[toBeReplaced] as Set