5

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"

Build parameters options

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 
Adir Dayan
  • 1,308
  • 13
  • 21
  • Do an echo VAPP_ID or vapHtml ...the thing is you're creating those values dynamically, so you still not see them... – rohit thomas Jun 23 '20 at 11:28
  • @rohitthomas, tried, it gets nothing. seems like if you create variable inside that groovy script, it will not be available in the Build steps, it's kind of "local variable". you was able to fetch the user inputs from html after press "Build" ? – Adir Dayan Jun 23 '20 at 12:47
  • What is the referenced paramters value ? do an echo of that – rohit thomas Jun 23 '20 at 15:40
  • 1
    https://plugins.jenkins.io/uno-choice/#Active%20Choices%20Reactive%20Reference%20Parameter read through Advance section they mention what needs to be done to get value in a build – rohit thomas Jun 23 '20 at 15:41

1 Answers1

12

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 :)

Adir Dayan
  • 1,308
  • 13
  • 21
  • How to get value of the input text using the id of the input text instead of build parameter name? The reason is that I am leaving build parameter name as blank. so that i can display or not display the entire parameter with label based on the another build parameter value. If I give build parameter name and i don't want to display the input box for some condition, only the input parameter name is displayed. – Jayakumari Arumugham Feb 26 '22 at 11:14