Skip to content

Commit

Permalink
Revert "feat: allow passing values to writePipelineEnv (#5261)" (#5262)
Browse files Browse the repository at this point in the history
This reverts commit ed2381b.
  • Loading branch information
D074360 authored Feb 11, 2025
1 parent ed2381b commit 2603f89
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions vars/writePipelineEnv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}
}

0 comments on commit 2603f89

Please sign in to comment.