问题
Presumably the parameters that are specified in a Jenkins workflow input step are available for consumption and conditional logic? How do we obtain those values? e.g. how do we obtain and reference true or false value for the checkbox parameter in the following:
input id: 'Proceed1', message: 'Proceed or abort?', parameters: [[$class: 'BooleanParameterDefinition', defaultValue: false, description: '', name: 'Please confirm you agree with this']]
回答1:
The return value of the input
step will be the submitted value (a boolean
, in the case of BooleanParameterDefinition
). If there are multiple parameters, you get a Map
so you can look up the value of each by name
.
By the way you can skip parameters
altogether if you simply want OK/Cancel semantics, as your example seems to imply. If the user cancels, the flow aborts. If they accept, there is no return value (well, null
technically).
回答2:
If you have just one value, you can retrieve it like this:
def userInput = input(
id: 'Proceed1', message: 'Proceed or abort?', parameters: [
[$class: 'BooleanParameterDefinition', defaultValue: false, description: '', name: 'Please confirm you agree with this']
])
From: https://cloudbees.zendesk.com/hc/en-us/articles/204986450-Pipeline-How-to-manage-user-inputs
来源:https://stackoverflow.com/questions/29906998/how-do-we-access-jenkins-workflow-input-parameter-values