From 6b4ac4bffafe6bfec2fd551df3387bc739b5dc2e Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 21 May 2019 11:53:33 +0200 Subject: [PATCH] input and output file as parameter --- resolvePlugins.sh | 2 +- steps.groovy | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/resolvePlugins.sh b/resolvePlugins.sh index 959f59679..2f270faf2 100755 --- a/resolvePlugins.sh +++ b/resolvePlugins.sh @@ -1,7 +1,7 @@ #!/bin/bash mvn clean test -groovy steps.groovy +groovy steps.groovy -in target/trackedCalls.json --out target/performedCalls.json WS_OUT="$(pwd)/jenkins_workspace" WS_IN=/workspace diff --git a/steps.groovy b/steps.groovy index 8a6efd4b4..4667999e6 100644 --- a/steps.groovy +++ b/steps.groovy @@ -1,6 +1,36 @@ import groovy.json.JsonSlurper -def steps = new JsonSlurper().parseText(new File('target/trackedCalls.json').text) +def cli = new CliBuilder( + usage: 'groovy createDocu []', + header: 'Options:', + footer: 'Copyright: SAP SE') + +cli.with { + i longOpt: 'in', args: 1, argName: 'file', 'The file containing the mapping as created by the unit tests..' + o longOpt: 'out', args: 1, argName: 'file', 'The file containing the condenced mappings.' + h longOpt: 'help', 'Prints this help.' +} + +def options = cli.parse(args) + +if(options.h) { + System.err << "Printing help.\n" + cli.usage() + return +} + +if(! options.i) { + System.err << "No input file" + cli.usage() + return +} +if(! options.o) { + System.err << "No output file" + cli.usage() + return +} + +def steps = new JsonSlurper().parseText(new File(options.i).text) def piperSteps = steps.piperSteps def calls = steps.calls @@ -76,7 +106,7 @@ for(def entry : calls.entrySet()) { piperStepCallMappings.put(entry.key, performedCalls) } -File performedCalls = new File('target/performedCalls.json') +File performedCalls = new File(options.o) if (performedCalls.exists()) performedCalls.delete() performedCalls << groovy.json.JsonOutput.toJson(piperStepCallMappings)