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

Matrix projects can't add Agents axis if a multi-line description is assigned to a label

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • matrix-project-plugin
    • None
    • OS: RHEL7.9
      Jenkins: 2.319.3 upgraded from 2.303.1
      Matrix Project plugin: 1.20 upgraded from 1.19
      Node and Label parameter plugin: 1.10.3 upgraded from 1.10.1

      After a Jenkins application and all plugins-update, new and existing multi-configuration projects have lost the ability to add an Agents axis.  Running through Chrome's debugger, this error displays when the Agents button is selected under the "Add axis" option.  

      Uncaught SyntaxError: Invalid or unexpected token 
        at eval (<anonymous>) 
        at geval (hudson-behavior.js:471:30)
        [...]

      This is occurring on two production servers, both of which have many nodes defined.  It is not occurring on two development servers, which only have three to six nodes defined.  . I added all the nodes from one production server to one dev server, but that did not have an impact.  

      In the /configure screen, when I select "Add axis" and then "Agents", no window and no errors are displayed in the GUI.  (In the dev environment, when I do that I get the Agents/Name/Node\Label window.)  I also note in dev I see a checkName "step", but that does not occur in prod.

      Using Chrome to see what I could figure out, I captured some errors.  Attached.

      Please let me know what additional information I can provide.  This is impacting existing multi-configuration projects, which no longer have the agents available to them.

          [JENKINS-67843] Matrix projects can't add Agents axis if a multi-line description is assigned to a label

          Mark Waite added a comment -

          You didn't mention the Jenkins version that you were using before your upgrade to Jenkins 2.319.3. If it was a Jenkins version prior to Jenkins 2.277.1, then you may have plugins installed that have not been updated to support modern configuration form layout that was added in Jenkins 2.277.1.

          See https://community.jenkins.io/t/migrating-jenkins/894/5 for a detailed description of the steps to be taken to investigate if the issue is related to configuration form layout.

          If that is not the issue, then you'll need to provide more details before others will be able to provide much help. Please provide the details as described in "How to report an issue".

          Mark Waite added a comment - You didn't mention the Jenkins version that you were using before your upgrade to Jenkins 2.319.3. If it was a Jenkins version prior to Jenkins 2.277.1, then you may have plugins installed that have not been updated to support modern configuration form layout that was added in Jenkins 2.277.1. See https://community.jenkins.io/t/migrating-jenkins/894/5 for a detailed description of the steps to be taken to investigate if the issue is related to configuration form layout. If that is not the issue, then you'll need to provide more details before others will be able to provide much help. Please provide the details as described in "How to report an issue" .

          Victoria added a comment -

          Hi, markewaite , thanks.  I upgraded Jenkins from version 2.303.1 to version 2.319.3.

          I paid particular attention to the information at https://www.jenkins.io/doc/upgrade-guide/2.319/#upgrading-to-jenkins-lts-2-319-1   regarding labels, but I just can't find any mitigation for my particular issue.  

          If I could figure out what 

          Uncaught SyntaxError: Invalid or unexpected token
              at eval (<anonymous>)
              at geval (hudson-behavior.js:471:30)
              at hudson-behavior.js:797:17
              at next (hudson-behavior.js:815:39)
              at sequencer (hudson-behavior.js:818:12)
              at evalInnerHtmlScripts (hudson-behavior.js:803:5)
              at hudson-behavior.js:774:9
              at onSuccess (bind.js:57:29)
              at klass.respondToReadyState (prototype.js:1657:37)
              at klass.onStateChange (prototype.js:1600:12)
          

          is telling me, that would be nice.  I'm not a developer, and I can't figure out where '<anonymous>' is coming from in the function in  hudson-behavior.js :

          /**
           * Evaluates the script in global context.
           */
          function geval(script) {
              // execScript chokes on "" but eval doesn't, so we need to reject it first.
              if (script==null || script=="") return;
              // see http://perfectionkills.com/global-eval-what-are-the-options/
              // note that execScript cannot return value
              (this.execScript || eval)(script);
          }
          
          

          I also turned on logging for hudson.matrix.MatrixProject, but that provides no info related to the lack of Agents being displayed.  Nothing is written to jenkins.log 

          I will restart one of the Jenkinses today, and then I'll attempt a downgrade on the Matrix Project and perhaps the Node and Label parameter plugins (to the prior versions as listed in "Environment" above).

          Thanks for the response.

           

          Victoria added a comment - Hi, markewaite , thanks.  I upgraded Jenkins from version 2.303.1 to version 2.319.3. I paid particular attention to the information at https://www.jenkins.io/doc/upgrade-guide/2.319/#upgrading-to-jenkins-lts-2-319-1   regarding labels, but I just can't find any mitigation for my particular issue.   If I could figure out what  Uncaught SyntaxError: Invalid or unexpected token at eval (<anonymous>) at geval (hudson-behavior.js:471:30) at hudson-behavior.js:797:17 at next (hudson-behavior.js:815:39) at sequencer (hudson-behavior.js:818:12) at evalInnerHtmlScripts (hudson-behavior.js:803:5) at hudson-behavior.js:774:9 at onSuccess (bind.js:57:29) at klass.respondToReadyState (prototype.js:1657:37) at klass.onStateChange (prototype.js:1600:12) is telling me, that would be nice.  I'm not a developer, and I can't figure out where '<anonymous>' is coming from in the function in  hudson-behavior.js : /** * Evaluates the script in global context. */ function geval(script) { // execScript chokes on "" but eval doesn't, so we need to reject it first. if (script== null || script=="") return ; // see http://perfectionkills.com/global-eval-what-are-the-options/ // note that execScript cannot return value ( this .execScript || eval)(script); } I also turned on logging for hudson.matrix.MatrixProject, but that provides no info related to the lack of Agents being displayed.  Nothing is written to jenkins.log  I will restart one of the Jenkinses today, and then I'll attempt a downgrade on the Matrix Project and perhaps the Node and Label parameter plugins (to the prior versions as listed in "Environment" above). Thanks for the response.  

          Mark Waite added a comment - - edited

          I don't recognize the specific details of that failure.

          I see several issues with the plugins you have installed that could cause problems when trying to save the job configuration.

          Two plugins that are not available from the Jenkins update center, watchr-jenkins, and ctestrecorder. They may have issues with the configuration form modernization that was done in Jenkins 2.277.1. I removed them from the list of plugins for my testing.

          Three plugins that are deprecated and should be removed (Pipeline: Declarative Agent API, Publish over SSH, and Multiple SCMS). Two of those plugins have issues reported that are related to configuration form modernization and could disrupt saving a configuration form change.

          Four plugins that have security issues and should be removed (GitLab Authentication, Publish over SSH, Project Inheritance, and Valgrind). One of those plugins (Valgrind) was last released 4 years and may have issues with configuration form modernization. One of those plugins (Publish over SSH) has a configuration form modernization issue reported.

          Disable those plugins, restart Jenkins, and see if that resolves the issue. If it does, then you'll need to remove those plugins or adopt them and fix the issues in them.

          I was unable to duplicate the problem that you reported, even without disabling those plugins. However, you have plugins installed that are known to cause issues with saving Jenkins configuration forms.

          Mark Waite added a comment - - edited I don't recognize the specific details of that failure. I see several issues with the plugins you have installed that could cause problems when trying to save the job configuration. Two plugins that are not available from the Jenkins update center, watchr-jenkins, and ctestrecorder. They may have issues with the configuration form modernization that was done in Jenkins 2.277.1. I removed them from the list of plugins for my testing. Three plugins that are deprecated and should be removed (Pipeline: Declarative Agent API, Publish over SSH, and Multiple SCMS). Two of those plugins have issues reported that are related to configuration form modernization and could disrupt saving a configuration form change. Four plugins that have security issues and should be removed (GitLab Authentication, Publish over SSH, Project Inheritance, and Valgrind). One of those plugins (Valgrind) was last released 4 years and may have issues with configuration form modernization. One of those plugins (Publish over SSH) has a configuration form modernization issue reported. Disable those plugins, restart Jenkins, and see if that resolves the issue. If it does, then you'll need to remove those plugins or adopt them and fix the issues in them. I was unable to duplicate the problem that you reported, even without disabling those plugins. However, you have plugins installed that are known to cause issues with saving Jenkins configuration forms.

          Victoria added a comment -

          Thanks, markewaite.  

          I disabled the plugins and still no joy.  I think my next steps will be to determine how many projects are using the multi-configuration project type, and ask my teammates and my manager just how much time they want me to sink into this.  I recognize the impossibility of solving a problem that you can't reproduce.  Reminding me that I can disable plugins was very helpful.

          Watchr is a homegrown application that does graphing.  https://github.com/sandialabs/watchr-jenkins.   The developer hasn't added it to the official Jenkins repo due to time constraints, IIRC.  The ctestrecorder is an ancient plugin that has something to do with CMake/CTest.  I believe it was developed in-house but was committed to the update center, but later abandoned.  

          Let's leave this issue open for a couple of days while I get coworkers to tell me what they think should be done. 

           

          Victoria added a comment - Thanks, markewaite .   I disabled the plugins and still no joy.  I think my next steps will be to determine how many projects are using the multi-configuration project type, and ask my teammates and my manager just how much time they want me to sink into this.  I recognize the impossibility of solving a problem that you can't reproduce.  Reminding me that I can disable plugins was very helpful. Watchr is a homegrown application that does graphing.  https://github.com/sandialabs/watchr-jenkins .   The developer hasn't added it to the official Jenkins repo due to time constraints, IIRC.  The ctestrecorder is an ancient plugin that has something to do with CMake/CTest.  I believe it was developed in-house but was committed to the update center, but later abandoned.   Let's leave this issue open for a couple of days while I get coworkers to tell me what they think should be done.   

          Victoria added a comment -

          If I can reproduce this on a non-production server, I'll update the closed ticket....

          Victoria added a comment - If I can reproduce this on a non-production server, I'll update the closed ticket....

          Justin Vallon added a comment -

          Was able to reproduce this.  We have (had) a label that had a newline in its description.  The generated script in geval was running code such as:

           new YAHOO.widget.HTMLNode("<input type=\'checkbox\' name=\'values\' json=\'xyz\' "+has("xyz")+"/><label class=\'attach-previous\'>xyz (first line
          second line
          )</label>", labels, false);

          Appears to be an unescaped newline in the generated script.

          Justin Vallon added a comment - Was able to reproduce this.  We have (had) a label that had a newline in its description.  The generated script in geval was running code such as: new YAHOO.widget.HTMLNode( "<input type=\ 'checkbox\' name=\ 'values\' json=\ 'xyz\' " +has( "xyz" )+"/><label class=\ 'attach-previous\' >xyz (first line second line )</label>", labels, false ); Appears to be an unescaped newline in the generated script.

          Justin Vallon added a comment -

          https://github.com/jenkinsci/matrix-project-plugin/blob/matrix-project-1.18.1/src/main/java/hudson/matrix/LabelAxis.java#L93 calls jsStringEscape, which does not escape newlines.

          To debug, use chrome JavaScript debugger and add a call to console.log("script: " + script); in the geval function, Ctrl-S, and the click "Add Agent".  Console will show the JavaScript being run before it throws the exception.

          Justin Vallon added a comment - https://github.com/jenkinsci/matrix-project-plugin/blob/matrix-project-1.18.1/src/main/java/hudson/matrix/LabelAxis.java#L93 calls jsStringEscape, which does not escape newlines. To debug, use chrome JavaScript debugger and add a call to console.log("script: " + script); in the geval function, Ctrl-S, and the click "Add Agent".  Console will show the JavaScript being run before it throws the exception.

          Mark Waite added a comment - - edited

          Same problem still exists on Jenkins 2.406 when multi-line descriptions are used for labels.

          Workaround is to replace multi-line descriptions on labels with single line descriptions.

          Mark Waite added a comment - - edited Same problem still exists on Jenkins 2.406 when multi-line descriptions are used for labels. Workaround is to replace multi-line descriptions on labels with single line descriptions.

            Unassigned Unassigned
            nm_v Victoria
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: