[JIRA] (JENKINS-46988) String.eachLine only reads first line

1,584 views
Skip to first unread message

kevin.nuckolls@gmail.com (JIRA)

unread,
May 11, 2019, 9:58:04 PM5/11/19
to jenkinsc...@googlegroups.com
Kevin Nuckolls commented on Bug JENKINS-46988
 
Re: String.eachLine only reads first line

I lost an afternoon to this bug and it's real and still open. The workaround mentioned of the split each works great. Just chiming in that this does actually need to be fixed.

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

katiersissons@gmail.com (JIRA)

unread,
May 22, 2019, 3:43:02 PM5/22/19
to jenkinsc...@googlegroups.com

Chiming in as well, having the same issue. Example:

	def tagged_branches = sh(returnStdout: true, script: "git branch --contains tags/${tag_name}")
	println tagged_branches
	tagged_branches.eachLine {
		println it
	}

Outputs:

12:36:41  + git branch --contains tags/v0.6.20
12:36:41  [Pipeline] echo
12:36:41    feature/install_from_net_drive
12:36:41  * master
12:36:41  
12:36:42  [Pipeline] echo
12:36:42    feature/install_from_net_drive
12:36:42  [Pipeline] }
12:36:42  [Pipeline] // script
12:36:42  [Pipeline] }

stefan.thurnherr@gmail.com (JIRA)

unread,
Aug 14, 2019, 4:05:03 AM8/14/19
to jenkinsc...@googlegroups.com

Just ran into this issue as well, but got this nice warning in the Jenkins output which helped me find the cause (i.e. this issue):

expected to call java.lang.String.eachLine but wound up catching org.jenkinsci.plugins.workflow.cps.CpsClosure2.call; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/

narakeshece12@gmail.com (JIRA)

unread,
Sep 19, 2019, 12:15:04 AM9/19/19
to jenkinsc...@googlegroups.com
node {
   def data = """# some useless text
                 |# even more
                 |finally interesting text"""
data.eachLine { String line ->
  println line
}

}

Same issue when we execute the above script.

expected to call java.lang.String.eachLine but wound up catching org.jenkinsci.plugins.workflow.cps.CpsClosure2.call; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

narakeshece12@gmail.com (JIRA)

unread,
Sep 19, 2019, 12:27:03 AM9/19/19
to jenkinsc...@googlegroups.com

Workaround is working really fine

As a workaround replace eachLine with split('\n').each { ... }

 

jrhett@netconsonance.com (JIRA)

unread,
Oct 17, 2019, 12:52:03 PM10/17/19
to jenkinsc...@googlegroups.com

jrhett@netconsonance.com (JIRA)

unread,
Oct 17, 2019, 1:05:09 PM10/17/19
to jenkinsc...@googlegroups.com
Jo Rhett edited a comment on Bug JENKINS-46988
I don't feel that this issue is Minor, nor do I feel that the workaround is an acceptable solution. This basically means that every Jenkins user worldwide will burn some hours diagnosing this problem only to end up here.

jrhett@netconsonance.com (JIRA)

unread,
Oct 17, 2019, 1:09:03 PM10/17/19
to jenkinsc...@googlegroups.com
Jo Rhett edited a comment on Bug JENKINS-46988
I don't feel that this issue is Minor, nor do I feel that the workaround is an acceptable solution. This basically means that every Jenkins user worldwide will burn some hours diagnosing this problem only to end up here.


That this bug is more than 2 years old speaks to a significant lack of care.

andrew@enospc.com (JIRA)

unread,
Jan 17, 2020, 4:49:04 PM1/17/20
to jenkinsc...@googlegroups.com

I'd like to affirm the previous comment.  I just did exactly that – I spent a couple of hours trying to figure out why my code wasn't working, and ended up here when I realized it was a bug in the Jenkins groovy interpreter for scripted pipelines.

dj.thornton@ascension.org (JIRA)

unread,
Feb 12, 2020, 4:03:02 PM2/12/20
to jenkinsc...@googlegroups.com

Likewise. Just burned a bit of time on this. Moving to the workaround.

piotr.b.kozuchowski@gmail.com (JIRA)

unread,
Mar 12, 2020, 8:50:03 AM3/12/20
to jenkinsc...@googlegroups.com

I've just stumbled over this as well.

This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages