1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-27 21:49:15 +02:00

Revert "feat: allow passing values to writePipelineEnv (#5261)" (#5262)

This reverts commit ed2381bc51224eb38508adc6a1bc54d848d90479.
This commit is contained in:
Manjunath 2025-02-11 15:59:03 +05:30 committed by GitHub
parent ed2381bc51
commit 2603f89f88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,27 +6,20 @@ import groovy.transform.Field
void call(Map parameters = [:]) {
final script = checkScript(this, parameters) ?: this
String piperGoPath = parameters?.piperGoPath ?: './piper'
String command = "${piperGoPath} writePipelineEnv"
if (parameters.value) {
command += " --value '${parameters.value}'"
}
Map cpe = script?.commonPipelineEnvironment?.getCPEMap(script)
if (cpe == null) return
def jsonMap = groovy.json.JsonOutput.toJson(cpe)
if (!jsonMap) {
script.echo("can't write pipelineEnvironment: empty environment")
if (cpe == null) {
return
}
withEnv(["PIPER_pipelineEnv=${jsonMap}"]) {
executeCommand(script, command, parameters?.verbose)
}
}
private void executeCommand(script, String command, boolean verbose) {
def output = script.sh(returnStdout: true, script: command)
if (verbose) {
script.echo("wrote commonPipelineEnvironment: ${output}")
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}")
}
}