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

LTS Jenkins scriptText endpoint returns leading spaces in its response

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • None
    • Jenkins version 2.176.2 LTS

      Expected Behavior

      Jenkins version 2.164.2 has the expected behavior.

      Calling the scriptText script console endpoint to get the Jenkins server version returns just the literal version.

      curl -XPOST --data-urlencode "script=println Jenkins.instance.version" -H 'Jenkins-Crumb:REDACTED' -H 'Authorization:Basic REDACTED' http://localhost:8080/scriptText
      

      Returns

      2.164.2
      

      Doing a word count for characters (wc -c) shows 8 characters (7 for the version number + 1 newline at the end because of using the println statement).

      Expected behavior:

      • scriptText returns only exactly the data that's returned from the script console running.
      • If using Groovy println it returns a trailing newline.
      • If using Groovy print it returns the version with no trailing newline.

      Buggy Behavior

      Since Jenkins version 2.176.2, the scriptText endpoint returns leading spaces in its response. Taking the same exact curl examples from above Jenkins scriptText returns

      \n
          \n
          2.176.2\n
      • It returns a leading newline.
      • Followed by four spaces and a newline.
      • Followed by four spaces and the data response from the script console execution.

      If using word count on characters (wc -c) the result is 18 characters (10 junk leading characters + 7 character version number + 1 newline character).

       

      For now, I have to strip / trim the response from scriptText in my automation scripts but the old behavior is desirable.

            Unassigned Unassigned
            sag47 Sam Gleske
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: