Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-47013

Exception parsing Spy log when Job name contains invalid XML characters (like "--")

      The plugin fails to parse the Spy logs when the Job name contains characters not accepted in XML comments.

      To reproduce the error it is enough to create a job with name TEST--job. The following message will appear in the Jenkins logs after the build finishes:

      ERROR: [withMaven] WARNING Exception parsing the logs generated by the Jenkins Maven Event Spy /srv/jslave/workspace/TEST--job@tmp/withMavena4ea94cc/maven-spy-20170920-180259-419.log, ignore file.  Please report a bug associated for the component 'pipeline-maven-plugin' at https://issues.jenkins-ci.org 
      ERROR: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 33; The string "--" is not permitted within comments.

      The plugin stores the job name as an XML comment in the Spy log and the job name is made of invalid characters for an XML comment.

      Tested with pipeline-maven-plugin version 3.0.0

          [JENKINS-47013] Exception parsing Spy log when Job name contains invalid XML characters (like "--")

          Bertrand Renuart created issue -
          Bertrand Renuart made changes -
          Description Original: The plugin fails to parse the Spy logs when the Job name contains characters not accepted in XML comments.

          To reproduce the error it is enough to create a job with name \{\{TEST–job}}. The following message will appear in the Jenkins logs after the build finishes:
          {code}
          ERROR: [withMaven] WARNING Exception parsing the logs generated by the Jenkins Maven Event Spy /srv/jslave/workspace/TEST--job@tmp/withMavena4ea94cc/maven-spy-20170920-180259-419.log, ignore file. Please report a bug associated for the component 'pipeline-maven-plugin' at https://issues.jenkins-ci.org
          ERROR: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 33; The string "--" is not permitted within comments.{code}

          The plugin stores the job name as an XML comment in the Spy log.
          New: The plugin fails to parse the Spy logs when the Job name contains characters not accepted in XML comments.

          To reproduce the error it is enough to create a job with name {{TEST--job}}. The following message will appear in the Jenkins logs after the build finishes:
          {code:java}
          ERROR: [withMaven] WARNING Exception parsing the logs generated by the Jenkins Maven Event Spy /srv/jslave/workspace/TEST--job@tmp/withMavena4ea94cc/maven-spy-20170920-180259-419.log, ignore file. Please report a bug associated for the component 'pipeline-maven-plugin' at https://issues.jenkins-ci.org
          ERROR: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 33; The string "--" is not permitted within comments.{code}
          The plugin stores the job name as an XML comment in the Spy log.
          Bertrand Renuart made changes -
          Description Original: The plugin fails to parse the Spy logs when the Job name contains characters not accepted in XML comments.

          To reproduce the error it is enough to create a job with name {{TEST--job}}. The following message will appear in the Jenkins logs after the build finishes:
          {code:java}
          ERROR: [withMaven] WARNING Exception parsing the logs generated by the Jenkins Maven Event Spy /srv/jslave/workspace/TEST--job@tmp/withMavena4ea94cc/maven-spy-20170920-180259-419.log, ignore file. Please report a bug associated for the component 'pipeline-maven-plugin' at https://issues.jenkins-ci.org
          ERROR: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 33; The string "--" is not permitted within comments.{code}
          The plugin stores the job name as an XML comment in the Spy log.
          New: The plugin fails to parse the Spy logs when the Job name contains characters not accepted in XML comments.

          To reproduce the error it is enough to create a job with name {{TEST--job}}. The following message will appear in the Jenkins logs after the build finishes:
          {code:java}
          ERROR: [withMaven] WARNING Exception parsing the logs generated by the Jenkins Maven Event Spy /srv/jslave/workspace/TEST--job@tmp/withMavena4ea94cc/maven-spy-20170920-180259-419.log, ignore file. Please report a bug associated for the component 'pipeline-maven-plugin' at https://issues.jenkins-ci.org
          ERROR: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 33; The string "--" is not permitted within comments.{code}
          The plugin stores the job name as an XML comment in the Spy log and the job name is made of invalid characters for an XML comment.
          Bertrand Renuart made changes -
          Description Original: The plugin fails to parse the Spy logs when the Job name contains characters not accepted in XML comments.

          To reproduce the error it is enough to create a job with name {{TEST--job}}. The following message will appear in the Jenkins logs after the build finishes:
          {code:java}
          ERROR: [withMaven] WARNING Exception parsing the logs generated by the Jenkins Maven Event Spy /srv/jslave/workspace/TEST--job@tmp/withMavena4ea94cc/maven-spy-20170920-180259-419.log, ignore file. Please report a bug associated for the component 'pipeline-maven-plugin' at https://issues.jenkins-ci.org
          ERROR: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 33; The string "--" is not permitted within comments.{code}
          The plugin stores the job name as an XML comment in the Spy log and the job name is made of invalid characters for an XML comment.
          New: The plugin fails to parse the Spy logs when the Job name contains characters not accepted in XML comments.

          To reproduce the error it is enough to create a job with name {{TEST--job}}. The following message will appear in the Jenkins logs after the build finishes:
          {code:java}
          ERROR: [withMaven] WARNING Exception parsing the logs generated by the Jenkins Maven Event Spy /srv/jslave/workspace/TEST--job@tmp/withMavena4ea94cc/maven-spy-20170920-180259-419.log, ignore file. Please report a bug associated for the component 'pipeline-maven-plugin' at https://issues.jenkins-ci.org
          ERROR: org.xml.sax.SAXParseException; lineNumber: 10; columnNumber: 33; The string "--" is not permitted within comments.{code}
          The plugin stores the job name as an XML comment in the Spy log and the job name is made of invalid characters for an XML comment.

          _Tested with pipeline-maven-plugin version 3.0.0_
          Cyrille Le Clerc made changes -
          Assignee Original: Alvaro Lobato [ alobato ] New: Cyrille Le Clerc [ cleclerc ]

          Cyrille Le Clerc added a comment - - edited

          brenuart can you please attach the xml log file generated by the Maven Event Spy?

          We document how to capture such log file on https://wiki.jenkins.io/display/JENKINS/Pipeline+Maven+Plugin#PipelineMavenPlugin-HowdoIcapturethelogfilegeneratedbytheJenkinsMavenEventSpy

           

          Don't forget to redact your file if you have secrets in it.

          Cyrille Le Clerc added a comment - - edited brenuart can you please attach the xml log file generated by the Maven Event Spy? We document how to capture such log file on https://wiki.jenkins.io/display/JENKINS/Pipeline+Maven+Plugin#PipelineMavenPlugin-HowdoIcapturethelogfilegeneratedbytheJenkinsMavenEventSpy   Don't forget to redact your file if you have secrets in it.

          The problem is that org.codehaus.plexus.util.xml.XmlWriterUtil.writeComment(XMLWriter writer, String comment) is NOT properly escaping the passed "comment". It does not escape "--"

          https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.0/maven-spy/src/main/java/org/jenkinsci/plugins/pipeline/maven/eventspy/JenkinsMavenEventSpy.java#L141

                  reporter.print("new File(.): " + new File(".").getCanonicalPath());
          
                  org.codehaus.plexus.util.xml.XmlWriterUtil.writeComment(xmlWriter, new Timestamp(System.currentTimeMillis()) + " - " + message);
          

          Cyrille Le Clerc added a comment - The problem is that org.codehaus.plexus.util.xml.XmlWriterUtil.writeComment(XMLWriter writer, String comment) is NOT properly escaping the passed "comment". It does not escape "--" https://github.com/jenkinsci/pipeline-maven-plugin/blob/pipeline-maven-3.0.0/maven-spy/src/main/java/org/jenkinsci/plugins/pipeline/maven/eventspy/JenkinsMavenEventSpy.java#L141 reporter.print( " new File(.): " + new File( "." ).getCanonicalPath()); org.codehaus.plexus.util.xml.XmlWriterUtil.writeComment(xmlWriter, new Timestamp( System .currentTimeMillis()) + " - " + message);

          That's indeed the case - do you still need me to capture the log file ?

          Bertrand Renuart added a comment - That's indeed the case - do you still need me to capture the log file ?

          brenuart correct, no need for additional log files.

          Cyrille Le Clerc added a comment - brenuart correct, no need for additional log files.

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          maven-spy/src/main/java/org/jenkinsci/plugins/pipeline/maven/eventspy/JenkinsMavenEventSpy.java
          http://jenkins-ci.org/commit/pipeline-maven-plugin/1e92c1337e6f50ecf126684652394419c3aec03b
          Log:
          JENKINS-47013 Fix XML file format when the file path of the working directory contains "--".
          Workaround the fact that org.codehaus.plexus.util.xml.XmlWriterUtil#writeComment(org.codehaus.plexus.util.xml.XMLWriter, java.lang.String) doesn't escaped the reserved char sequence '--'

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: maven-spy/src/main/java/org/jenkinsci/plugins/pipeline/maven/eventspy/JenkinsMavenEventSpy.java http://jenkins-ci.org/commit/pipeline-maven-plugin/1e92c1337e6f50ecf126684652394419c3aec03b Log: JENKINS-47013 Fix XML file format when the file path of the working directory contains "--". Workaround the fact that org.codehaus.plexus.util.xml.XmlWriterUtil#writeComment(org.codehaus.plexus.util.xml.XMLWriter, java.lang.String) doesn't escaped the reserved char sequence '--'

            cleclerc Cyrille Le Clerc
            brenuart Bertrand Renuart
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: