The problem here is you need to either interpolate the Groovy variable within Groovy if you are passing it to the shell step method for interpretation, or use it as a first class expression within Groovy.
Showing examples for both of these possibilities:
script {
def destroyCluster = input(
id: 'destroyCluster',
message: 'Destroy cluster ?',
parameters: [[$class: 'BooleanParameterDefinition',
defaultValue: false,
description: 'Destroy cluster',
name: 'destroy']])
echo "Destroy: ${destroyCluster}" // proper Groovy interpolation
print destroyCluster // first class expression
If nothing is still output to standard out in the Jenkins Pipeline logs, then destroyCluster
is a void
type method and does not return anything. In that case, you will be unable to assign and utilize its return value.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…