Empty HTML with AC Reactive Reference parameter passing in Job

9 views
Skip to first unread message

Leslie Klein

unread,
Apr 4, 2016, 1:24:43 AM4/4/16
to BioUno Developers
Hi
I am reading a YAML file, parsing into html and updating the values. This is working fine with the AC Reactive Reference parameter. But when I try to pass html that has been updated (to write the original YAML file using another AC ref parameter), it contains only "FONT FACE".  What seems to be happening is that the first equal sign in the code (after FONT FACE) is parsing value of html. Choice type is Formatted HTML The input YAML file is referenced from binding.variables.get('Composer_servers')
TIA 


this.class.classLoader.parseClass("C:/IBM/RationalSDLC/ClearQuest/snakeyaml-1.9.jar")

import jenkins.model.Jenkins

import org.yaml.snakeyaml.*

import org.yaml.snakeyaml.constructor.*

import java.util.Map 

 

def jenkinsHome = Jenkins.instance.getRootDir()

def fp = "d:\\Jenkins\\userContent\\Chn\\info\\newcomp\\compconfig\\"

def fn = binding.variables.get('Composer_servers')

def  f1 =  [fp,fn]

def f2 = f1.join("")

def f3 = "d:\\Jenkins\\userContent\\Chn\\info\\newcomp\\compconfig\\temxpxx.txt"


def yaml = new Yaml() 

def map

pr = new File(f2).text

Yaml configyml = new Yaml()

map = configyml.load(pr)

 

html ="<FONT FACE=\"Courier New\" size = \"3\" color=\"red\"><U><b>${map.keySet()}</b></U></FONT>"

map.each {k, v ->    

  v.each {x, y ->

  html = html + "<br></br><FONT FACE=\"Courier New\" size = \"3\" color=\"green\"><u>${x}</u></FONT>"

        y.each {

          it.each {p, q ->     

           if (p =~ /item/ ){  

             html = html + "<FONT FACE=\"Courier New\" size = \"3\" color=\"indigo\"><br></br>"   }

          else {

            html = html + "<FONT FACE=\"Courier New\" size = \"3\" color=\"blue\"><br></br>"   }

             html = html + "<B>"+p.padRight(28,'.')+"</B></FONT>"

              if (p != 'item') {

               html = html + "<textarea name=\"text\" cols=\"40\" rows = \"1\">"

                          html = html+"${q}"

                          html = html+"</textarea>"

                          }

                        }

                     }

           }

   }

 

return "<input name= \"value\" value = \"${html}\" class=\"setting-input\" type=\"text\">"

Bruno P. Kinoshita

unread,
Apr 6, 2016, 6:50:54 AM4/6/16
to biouno-d...@googlegroups.com
Hi Leslie!

If you can simplify your example, perhaps I could try to reproduce it locally.

However, a quick test before that would be to encode the string. I think your suspicion might be correct, and indeed the = could be confusing the query string.

Try URL encoding the contents of the variable, or some other encoding (e.g. Base64). Then you may have to decode it as well before using it ;-)

Hope that helps
Bruno



From: Leslie Klein <klei...@gmail.com>
To: BioUno Developers <biouno-d...@googlegroups.com>
Sent: Monday, 4 April 2016 5:24 PM
Subject: Empty HTML with AC Reactive Reference parameter passing in Job

Hi
I am reading a YAML file, parsing into html and updating the values. This is working fine with the AC Reactive Reference parameter. But when I try to pass html that has been updated (to write the original YAML file using another AC ref parameter), it contains only "FONT FACE".  What seems to be happening is that the first equal sign in the code (after FONT FACE) is parsing value of html. Choice type is Formatted HTML The input YAML file is referenced from binding.variables.get('Composer_servers')
TIA 


this.class.classLoader. parseClass("C:/IBM/ RationalSDLC/ClearQuest/ snakeyaml-1.9.jar")
import jenkins.model.Jenkins
import org.yaml.snakeyaml.*
import org.yaml.snakeyaml.constructor .*
import java.util.Map 
 
def jenkinsHome = Jenkins.instance.getRootDir()
def fp = "d:\\Jenkins\\userContent\\ Chn\\info\\newcomp\\compconfig \\"
def fn = binding.variables.get(' Composer_servers')
def  f1 =  [fp,fn]
def f2 = f1.join("")
def f3 = "d:\\Jenkins\\userContent\\ Chn\\info\\newcomp\\ compconfig\\temxpxx.txt"

def yaml = new Yaml() 
def map
pr = new File(f2).text
Yaml configyml = new Yaml()
map = configyml.load(pr)
 
html ="<FONT FACE=\"Courier New\" size = \"3\" color=\"red\"><U><b>${map. keySet()}</b></U></FONT>"
map.each {k, v ->    
  v.each {x, y ->
  html = html + "<br></br><FONT FACE=\"Courier New\" size = \"3\" color=\"green\"><u>${x}</u></ FONT>"
        y.each {
          it.each {p, q ->     
           if (p =~ /item/ ){  
             html = html + "<FONT FACE=\"Courier New\" size = \"3\" color=\"indigo\"><br></br>"   }
          else {
            html = html + "<FONT FACE=\"Courier New\" size = \"3\" color=\"blue\"><br></br>"   }
             html = html + "<B>"+p.padRight(28,'.')+"</B> </FONT>"
              if (p != 'item') {
               html = html + "<textarea name=\"text\" cols=\"40\" rows = \"1\">"
                          html = html+"${q}"
                          html = html+"</textarea>"
                          }
                        }
                     }
           }
   }
 
return "<input name= \"value\" value = \"${html}\" class=\"setting-input\" type=\"text\">"
--
You received this message because you are subscribed to the Google Groups "BioUno Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biouno-develop...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Leslie Klein

unread,
Apr 6, 2016, 8:08:39 AM4/6/16
to BioUno Developers
Hi Bruno,
you are right about the encoding, changing the return value of the html to
return "<input name= \"value\" value = \"${URLEncoder.encode(html,"UTF-8")}\" class=\"setting-input\" type=\"text\">"

does pass the string in the build. However, the html is invalidated and cannot be rendered within the AC control.

Thanks
Leslie

Bruno P. Kinoshita

unread,
Apr 6, 2016, 5:23:29 PM4/6/16
to biouno-d...@googlegroups.com
Hi Leslie,

The <input type=value value=... /> is supposed to contain the value passed to Jenkins, that may be used in the Job. In that case, you could encode the HTML, and decode in your job.

But if you want to display the HTML on the screen, then you can do something like:

return "${html}<input type='value' value='${encodedHTML}' ... />"

This way your HTML will be rendered on the job parameter screen, and the value will be passed to the job encoded (if necessary, if not simply do not include that value and remember to not check the omit value advanced setting)

Hope that helps,
Bruno



From: Leslie Klein <klei...@gmail.com>
To: BioUno Developers <biouno-d...@googlegroups.com>
Sent: Thursday, 7 April 2016 12:08 AM
Subject: Re: Empty HTML with AC Reactive Reference parameter passing in Job

Hi Bruno,
you are right about the encoding, changing the return value of the html to
return "<input name= \"value\" value = \"${URLEncoder.encode(html,"UTF-8")}\" class=\"setting-input\" type=\"text\">"

does pass the string in the build. However, the html is invalidated and cannot be rendered within the AC control.

Thanks
Leslie



On Monday, April 4, 2016 at 8:24:43 AM UTC+3, Leslie Klein wrote:
Hi
I am reading a YAML file, parsing into html and updating the values. This is working fine with the AC Reactive Reference parameter. But when I try to pass html that has been updated (to write the original YAML file using another AC ref parameter), it contains only "FONT FACE".  What seems to be happening is that the first equal sign in the code (after FONT FACE) is parsing value of html. Choice type is Formatted HTML The input YAML file is referenced from binding.variables.get('Co mposer_servers')
TIA 


this.class.classLoader. parseClass("C:/IBM/ RationalSDLC/ClearQuest/ snakeyaml-1.9.jar")
import jenkins.model.Jenkins
import org.yaml.snakeyaml.*
import org.yaml.snakeyaml.constructor .*
import java.util.Map 
 
def jenkinsHome = Jenkins.instance.getRootDir()
def fp = "d:\\Jenkins\\userContent\\ Chn\\info\\newcomp\\compconfig \\"
def fn = binding.variables.get(' Composer_servers')
def  f1 =  [fp,fn]
def f2 = f1.join("")
def f3 = "d:\\Jenkins\\userContent\\ Chn\\info\\newcomp\\ compconfig\\temxpxx.txt"

def yaml = new Yaml() 
def map
pr = new File(f2).text
Yaml configyml = new Yaml()
map = configyml.load(pr)
 
html ="<FONT FACE=\"Courier New\" size = \"3\" color=\"red\"><U><b>${map. keySet()}</b></U></FONT>"
map.each {k, v ->    
  v.each {x, y ->
  html = html + "<br></br><FONT FACE=\"Courier New\" size = \"3\" color=\"green\"><u>${x}</u></ FONT>"
        y.each {
          it.each {p, q ->     
           if (p =~ /item/ ){  
             html = html + "<FONT FACE=\"Courier New\" size = \"3\" color=\"indigo\"><br></br>"   }
          else {
            html = html + "<FONT FACE=\"Courier New\" size = \"3\" color=\"blue\"><br></br>"   }
             html = html + "<B>"+p.padRight(28,'.')+"</B> </FONT>"
              if (p != 'item') {
               html = html + "<textarea name=\"text\" cols=\"40\" rows = \"1\">"
                          html = html+"${q}"
                          html = html+"</textarea>"
                          }
                        }
                     }
           }
   }
 
return "<input name= \"value\" value = \"${html}\" class=\"setting-input\" type=\"text\">"
--

Leslie Klein

unread,
Apr 7, 2016, 2:11:22 AM4/7/16
to BioUno Developers, brunod...@yahoo.com.br
Thanks Bruno, that works!
Reply all
Reply to author
Forward
0 new messages