[JIRA] (JENKINS-59077) Jenkins scriptText endpoint returns leading spaces in its response

5 views
Skip to first unread message

sam.mxracer@gmail.com (JIRA)

unread,
Aug 26, 2019, 1:05:02 AM8/26/19
to jenkinsc...@googlegroups.com
Sam Gleske created an issue
 
Jenkins / Bug JENKINS-59077
Jenkins scriptText endpoint returns leading spaces in its response
Issue Type: Bug Bug
Assignee: Unassigned
Components: core
Created: 2019-08-26 05:04
Environment: Jenkins version 2.176.2
Priority: Minor Minor
Reporter: Sam Gleske

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 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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

sam.mxracer@gmail.com (JIRA)

unread,
Aug 26, 2019, 1:09:02 AM8/26/19
to jenkinsc...@googlegroups.com
Sam Gleske updated an issue
Change By: Sam Gleske
h2. 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.
{noformat}

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

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.

h2. 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
{noformat}

\n
    \n
    2.176.2\n{noformat}
* 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.

sam.mxracer@gmail.com (JIRA)

unread,
Aug 26, 2019, 1:52:01 AM8/26/19
to jenkinsc...@googlegroups.com
Sam Gleske commented on Bug JENKINS-59077
 
Re: Jenkins scriptText endpoint returns leading spaces in its response

Looks like a dupe of JENKINS-58548.  Seems this bug has made it into the LTS version of Jenkins.  I'll leave this issue open for now so that the Jenkins core team can review and close it.

Leaving for core team review considering it made it to LTS.

Reply all
Reply to author
Forward
0 new messages