mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-03-05 15:15:44 +02:00
input and output file as parameter
This commit is contained in:
parent
a911cc400e
commit
6b4ac4bffa
@ -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
|
||||
|
34
steps.groovy
34
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 [<options>]',
|
||||
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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user