1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/vars/writePipelineEnv.groovy

26 lines
902 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)
if (piperGoPath && jsonMap) {
withEnv(["PIPER_pipelineEnv=${jsonMap}"]) {
def output = script.sh(returnStdout: true, script: "${piperGoPath} writePipelineEnv")
if (parameters?.verbose) {
script.echo("wrote commonPipelineEnvironment: ${output}")
}
}
} else {
script.echo("can't write pipelineEnvironment: piperGoPath: ${piperGoPath} piperEnvironment ${jsonMap}")
}
}