1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/vars/writePipelineEnv.groovy
Kevin Stiehl eb6ffc334a
[CPE] write commonPipelineEnvironment even when it's empty (#2904)
* writePipelineEnv even when map is empty

* mock write and read PipelineEnv calls
2021-06-15 18:42:04 +02:00

22 lines
622 B
Groovy

import static com.sap.piper.Prerequisites.checkScript
import groovy.transform.Field
@Field def STEP_NAME = getClass().getName()
void call(Map parameters = [:]) {
final script = checkScript(this, parameters) ?: this
String piperGoPath = parameters.piperGoPath ?: './piper'
Map cpe = script.commonPipelineEnvironment.getCPEMap(script)
if (cpe == null) {
return
}
def jsonMap = groovy.json.JsonOutput.toJson(cpe)
def writePipelineEnvCommand = """
${piperGoPath} writePipelineEnv <<EOF
${jsonMap}
EOF
"""
def output = script.sh(returnStdout: true, script: writePipelineEnvCommand)
}