[JIRA] (JENKINS-54657) dropWhile doesn't behave correctly

1 view
Skip to first unread message

jostein.gogstad@gmail.com (JIRA)

unread,
Nov 15, 2018, 1:37:02 PM11/15/18
to jenkinsc...@googlegroups.com
Jostein Gogstad created an issue
 
Jenkins / Bug JENKINS-54657
dropWhile doesn't behave correctly
Issue Type: Bug Bug
Assignee: Unassigned
Components: pipeline
Created: 2018-11-15 18:36
Priority: Major Major
Reporter: Jostein Gogstad

The following pipeline outputs 1 2 3 true, the expected output is 1 2 3 [2,3],  

pipeline {
    stages {
        stage('Testing groovy closures') {
            steps {
                script {
                    [1, 2, 3].each { println(it) }
                    def a = [1, 2, 3].dropWhile { it != 2 }
                    println(a)
                }
            }
        }
    }
} 

Running Pipeline Groovy Plugin 2.60

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

amdokamal@gmail.com (JIRA)

unread,
Jun 21, 2019, 5:21:02 AM6/21/19
to jenkinsc...@googlegroups.com
S. Panchenko commented on Bug JENKINS-54657
 
Re: dropWhile doesn't behave correctly

Workaround: create NonCPS-function in a shared library:

@NonCPS
static dropWhileIfNotFound(final c, final search_item) {
  return c.dropWhile{ it != search_item }
}

 

Reply all
Reply to author
Forward
0 new messages