LTS Jenkins scriptText endpoint returns leading spaces in its response

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor
    • Component/s: core
    • Environment:
      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.

            Assignee:
            Unassigned
            Reporter:
            Sam Gleske
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: