Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

rest/builds/ failure because of the special characters #4227

seungpil.oh ·

Hello.

If description of perforce CL include special characters, a build using the CL cannot used by rest api.

We use perforce repository.
"QB build" has repository information and it includes description info.


sample.png ----------

If there are some special characters, the build rest api return fail.
restapi_failure.png

  • replies 8
  • views 144
  • stars 0
robinshen ADMIN ·

Please switch to pipelines page and point mouse to commit info of the repository like below to see if the message is displayed correctly.

2020-04-18_13-47-29.png
seungpil.oh ·

I can see the comment on the pipeline. but rest api is failed.
It's part of P4 description
p4_description.png

And it's part of pipeline comment.
pipe_line_comment.png

robinshen ADMIN ·

Are you able to backup the database via "administration / database backup" page? If so, please send me [robin AT pmease DOT com] the backup and let me know which build is in problem.

seungpil.oh ·

I checked the xml file on the cmd window and it was no problem.
As you said, it seem the browser issue.
Thank you very much.

seungpil.oh ·

Hello. Robin.

I made a step with below script to get build info from another QBM.

groovy:
import com.pmease.quickbuild.QuickbuildException
import com.pmease.quickbuild.plugin.report.engine.util.XMLHelper

qbm = "https://qbbuildsite.net"
build_id = 123456789

def cmd = "curl -u ${vars.get("ID")}:${vars.get("PW")} " + qbm + "/rest/builds/" + build_id
XMLHelper.readXML(util.readOutput(cmd));

But it has got below error because of special characters which made by the commit info of repository

Step 'master>xml parser' is failed: java.lang.RuntimeException: org.dom4j.DocumentException: Error on line 167 of document : Character reference "&# Nested exception: Character reference "&#
    at com.google.common.base.Throwables.propagate(Throwables.java:160)
    at com.pmease.quickbuild.plugin.report.engine.util.XMLHelper.readXML(XMLHelper.java:247)
    at com.pmease.quickbuild.plugin.report.engine.util.XMLHelper$readXML.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)

So it has no problem in the cmd window and pipelines but "readXML" function has a issue for it.
Do you have idea to resolve this issue?

robinshen ADMIN ·

Please upgrade to QB 10.0.13 and change your code like below to see if it works:

groovy:
import com.pmease.quickbuild.QuickbuildException
import com.pmease.quickbuild.plugin.report.engine.util.XMLHelper

qbm = "https://qbbuildsite.net"
build_id = 123456789

def cmd = "curl -u ${vars.get("ID")}:${vars.get("PW")} " + qbm + "/rest/builds/" + build_id
XMLHelper.readXML(util.readOutput(cmd, "UTF-8"));
seungpil.oh ·

It does Not work.
I have updated to 10.0.13 and changed my script.
But it has same issue.

The first line of the xml is " "
and the 167 line is "<&>S 1q3.972112] 0:"

robinshen ADMIN ·

Looks like XMLHelper is not able to deal with this special character. I changed to use XPP3Reader and it works

groovy:

import org.dom4j.io.XPP3Reader

def cmd = "curl -u admin:admin http://localhost:8810/rest/builds/1"
def xml = util.readOutput(cmd, "UTF-8")
def doc = new XPP3Reader().read(xml.toCharArray())
logger.info(doc.selectNodes("//comment").get(0).getText())