mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-04-09 07:13:58 +02:00
feat: allow passing values to writePipelineEnv (#5261)
This commit is contained in:
parent
8895891860
commit
ed2381bc51
@ -6,20 +6,27 @@ import groovy.transform.Field
|
|||||||
void call(Map parameters = [:]) {
|
void call(Map parameters = [:]) {
|
||||||
final script = checkScript(this, parameters) ?: this
|
final script = checkScript(this, parameters) ?: this
|
||||||
String piperGoPath = parameters?.piperGoPath ?: './piper'
|
String piperGoPath = parameters?.piperGoPath ?: './piper'
|
||||||
Map cpe = script?.commonPipelineEnvironment?.getCPEMap(script)
|
String command = "${piperGoPath} writePipelineEnv"
|
||||||
if (cpe == null) {
|
|
||||||
return
|
if (parameters.value) {
|
||||||
|
command += " --value '${parameters.value}'"
|
||||||
}
|
}
|
||||||
|
Map cpe = script?.commonPipelineEnvironment?.getCPEMap(script)
|
||||||
|
if (cpe == null) return
|
||||||
|
|
||||||
def jsonMap = groovy.json.JsonOutput.toJson(cpe)
|
def jsonMap = groovy.json.JsonOutput.toJson(cpe)
|
||||||
if (piperGoPath && jsonMap) {
|
if (!jsonMap) {
|
||||||
withEnv(["PIPER_pipelineEnv=${jsonMap}"]) {
|
script.echo("can't write pipelineEnvironment: empty environment")
|
||||||
def output = script.sh(returnStdout: true, script: "${piperGoPath} writePipelineEnv")
|
return
|
||||||
if (parameters?.verbose) {
|
}
|
||||||
script.echo("wrote commonPipelineEnvironment: ${output}")
|
withEnv(["PIPER_pipelineEnv=${jsonMap}"]) {
|
||||||
}
|
executeCommand(script, command, parameters?.verbose)
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
script.echo("can't write pipelineEnvironment: piperGoPath: ${piperGoPath} piperEnvironment ${jsonMap}")
|
|
||||||
|
private void executeCommand(script, String command, boolean verbose) {
|
||||||
|
def output = script.sh(returnStdout: true, script: command)
|
||||||
|
if (verbose) {
|
||||||
|
script.echo("wrote commonPipelineEnvironment: ${output}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user