1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00

fix code climate issues

This commit is contained in:
Marcus Holl 2019-05-17 14:52:27 +02:00
parent d7d36c9445
commit a24c89ce12
4 changed files with 30 additions and 27 deletions

View File

@ -39,7 +39,7 @@ def resolvePlugin(call) {
for(def pd in pDescs) { for(def pd in pDescs) {
if(pd.getSymbol() == call) if(pd.getSymbol() == call)
return pd.real.plugin?.shortName return pd.real.plugin?.shortName
} }
return null return null
} }

View File

@ -7,15 +7,15 @@ def stepPluginMapping = [:]
println "[INFO] Resolving plugins ..." println "[INFO] Resolving plugins ..."
for(def step in stepCallMapping) { for(def step in stepCallMapping) {
def resolvedPlugins = [:] def resolvedPlugins = [:]
for(def call in step.value) { for(def call in step.value) {
def resolvedPlugin = resolvePlugin(call) def resolvedPlugin = resolvePlugin(call)
if (! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED' if (! resolvedPlugin) resolvedPlugin = 'UNIDENTIFIED'
if(resolvedPlugins[resolvedPlugin] == null) if(resolvedPlugins[resolvedPlugin] == null)
resolvedPlugins[resolvedPlugin] = (Set)[] resolvedPlugins[resolvedPlugin] = (Set)[]
resolvedPlugins[resolvedPlugin] << call resolvedPlugins[resolvedPlugin] << call
stepPluginMapping.put(step.key,resolvedPlugins) stepPluginMapping.put(step.key,resolvedPlugins)
} }
} }
def result = System.getenv()['result'] def result = System.getenv()['result']
@ -35,8 +35,7 @@ def resolvePlugin(call) {
for(def pd in pDescs) { for(def pd in pDescs) {
if(pd.getSymbol() == call) if(pd.getSymbol() == call)
return pd.real.plugin?.shortName return pd.real.plugin?.shortName
} }
return null return null
} }

View File

@ -5,26 +5,26 @@ groovy steps.groovy
[ -d jenkins_home ] && rm -rf jenkins_home [ -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); 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}"; echo "ContainerId: ${cID}"
while true while true
do do
[ -f jenkins_home/piper/result.json ] && { docker rm -f ${cID}; break; } # normal ... [ -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 [ -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 docker ps --no-trunc |grep -q "${cID}"|| break # docker container does not run anymore
echo "[INFO] waiting for results" echo "[INFO] waiting for results"
sleep 10 sleep 10
done done
RESULT="`pwd`/jenkins_home/piper/result.json" RESULT="$(pwd)/jenkins_home/piper/result.json"
[ -f ${RESULT} ] && cat jenkins_home/piper/result.json [ -f "${RESULT}" ] && cat jenkins_home/piper/result.json

View File

@ -18,7 +18,7 @@ _calls = null
// Remove selfs // Remove selfs
calls.each { c -> calls.each { c ->
c.value.remove(c.key) c.value.remove(c.key)
} }
int counter=0 int counter=0
@ -42,7 +42,11 @@ while(counter < 1600) {
for (def calledStep in calledSteps) { 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 { } else {
if(calledStep in piperSteps) { if(calledStep in piperSteps) {
toBeReplaced = calledStep toBeReplaced = calledStep
@ -50,7 +54,7 @@ while(counter < 1600) {
break break
} }
} }
} }
if(toBeReplaced) { if(toBeReplaced) {
def replacement = [:] def replacement = [:]
replacement[toBeReplaced] = calls[toBeReplaced] as Set replacement[toBeReplaced] = calls[toBeReplaced] as Set