How to get user inputs from Jenkins Active Choice parameter using Formatted HTML

删除回忆录丶 提交于 2020-07-10 10:28:16

问题


I defined parameter of type "Active Choices Reactive Reference Parameter" on Freestyle Job

it returns HTML text input - <input>. but after populating this data and press "Build" i can't get the user input of this text field, tried with groovy or shell steps, for the parameter name itself i get empty string.

it's possible somehow to fetch the value of below field VAPP_ID ? suppose to get "123"

This is the groovy script of this Formatted HTML:

vappHtml = '''
<ul style="list-style-type: none">
  <li>
    <label for="VAPP_ID">VAPP_ID</label>
    <input type="text" id="VAPP_ID" name="VAPP_ID">
  </li>
</ul>
'''

return vappHtml 

回答1:


Finally i found what is the exact input definition needed to be able to fetch the data later in build steps.

groovy script:

vappHtml = '''
<ul style="list-style-type: none">
    <li style="padding: 5px">
    <label>VAPP_ID</label>
    <input type="text" class="setting-input" name="value">
  </li>
</ul>
'''

return vappHtml

How to actually fetch the data:

in build steps, like Shell, just get the original build parameter in my case it's $Env_Details

i was missing for 2 mandatory attributes for the <input>

  • class="setting-input"
  • name="value" (the name must be 'value' and nothing else)

Note - In case you want to use multiple input fields, just give all of them the same name attribute: name="value", in the result, it will just give you all the fields values separated by "," delimiter, so you can split it in groovy or something.

Hope it will help someone :)



来源:https://stackoverflow.com/questions/62532153/how-to-get-user-inputs-from-jenkins-active-choice-parameter-using-formatted-html

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