-
Task
-
Resolution: Not A Defect
-
Minor
-
None
-
Jenkins 2.32.2, Active Choices 1.5.2, Chrome v. 56
Using an Active Choices Reactive Reference Parameter and having it return Formatted HTML with a script portion (onchange, etc...) works great unless the groovy script references other dependent build parameters such as strings, Active Choice parameters, etc... The returned HTML renders properly, just without the script. Attached is a (hopefully) very simple job configuration to demonstrate.
The groovy script for generating the sample test is as follows (DummyVar is a string parameter defined just above this parameter):
//Uncomment this line, causing DummyVar to be referenced, and the script will be lost at runtime. //def a = DummyVar def FullHTML = "" FullHTML += "<head>" FullHTML += "<script type='text/javascript'> jQuery(document).on('ready', function() { function updateOutputValue() { jQuery('#value').val('Booya!'); };" FullHTML += " updateOutputValue();" FullHTML += "});" FullHTML += "</script>" FullHTML += "</head>" FullHTML += "<body><form><input id='value' name='value' > </form></body>" return FullHTML
- is related to
-
JENKINS-45507 Evaluate parameters once
-
- Open
-
[JENKINS-42034] Reactive Reference parameter with Formated HTML loses script section when binding to other build parameters
Description |
Original:
Using an Active Choices Reactive Reference Parameter and having it return Formatted HTML with a script portion (onchange, etc...) works great unless the groovy script references other dependent build parameters such as strings, Active Choice parameters, etc... The returned HTML renders properly, just without the script. Attached is a (hopefully) very simple job configuration to demonstrate. The groovy script for generating the sample test is as follows (DummyVar is a string parameter defined just above this parameter): ----------------------------------------------------------------------------------- //Uncomment this line, causing DummyVar to be referenced, and the script will be lost at runtime. //def a = DummyVar def FullHTML = "" FullHTML += "<head>" FullHTML += "<script type='text/javascript'> jQuery(document).on('ready', function() { function updateOutputValue() { jQuery('#value').val('Booya!'); };" FullHTML += " updateOutputValue();" FullHTML += "});" FullHTML += "</script>" FullHTML += "</head>" FullHTML += "<body><form><input id='value' name='value' > </form></body>" return FullHTML ----------------------------------------------------------------------------------- |
New:
Using an Active Choices Reactive Reference Parameter and having it return Formatted HTML with a script portion (onchange, etc...) works great unless the groovy script references other dependent build parameters such as strings, Active Choice parameters, etc... The returned HTML renders properly, just without the script. Attached is a (hopefully) very simple job configuration to demonstrate. The groovy script for generating the sample test is as follows (DummyVar is a string parameter defined just above this parameter): {code} //Uncomment this line, causing DummyVar to be referenced, and the script will be lost at runtime. //def a = DummyVar def FullHTML = "" FullHTML += "<head>" FullHTML += "<script type='text/javascript'> jQuery(document).on('ready', function() { function updateOutputValue() { jQuery('#value').val('Booya!'); };" FullHTML += " updateOutputValue();" FullHTML += "});" FullHTML += "</script>" FullHTML += "</head>" FullHTML += "<body><form><input id='value' name='value' > </form></body>" return FullHTML {code} |
Assignee | Original: Bruno P. Kinoshita [ kinow ] | New: Ioannis Moutsatsos [ ioannis ] |
Attachment | New: config[1].xml [ 36404 ] |
Attachment | New: screenshot-1.png [ 36405 ] |
Status | Original: Open [ 1 ] | New: In Progress [ 3 ] |
Resolution | New: Not A Defect [ 7 ] | |
Status | Original: In Progress [ 3 ] | New: Closed [ 6 ] |
I'm not sure referencing the parameter is the problem. Your script is returning HTML with a <script> tag. The plug-in includes the HTML you provided using innerHTML. That may be the problem.
ioannis has way more experience than I using JavaScript with the reactive parameters. Ioannis, could you take a look at this script, please? Would be great if you could confirm it there's a bug in the plug-in behaviour. Looking at the code, I can't really understand what's going on, except that script tag is never evaluated, as far as I can tell.