How do we access Jenkins workflow input parameter values?

纵饮孤独 提交于 2019-12-24 13:13:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!