[JIRA] (JENKINS-58552) .split('.') method works incorrect

4 views
Skip to first unread message

rostergek@gmail.com (JIRA)

unread,
Jul 18, 2019, 9:59:02 AM7/18/19
to jenkinsc...@googlegroups.com
gek created an issue
 
Jenkins / Bug JENKINS-58552
.split('.') method works incorrect
Issue Type: Bug Bug
Assignee: vjuranek
Components: groovy-plugin, pipeline
Created: 2019-07-18 13:58
Environment: Jenkins 2.164.1
Pipeline:groovy 2.70
Priority: Minor Minor
Reporter: gek

 

Hello! When i use .slit() method with '.' as delimiter, it's work incorrectly. If i use any other char, like ',' - it's work as expected, but not with '.'

 

Problem code:

script {
    RC_FILES = '4,5,6'
    println RC_FILES.getClass()

    VERSION_TAIL_0 = '1.2.3'
    println VERSION_TAIL_0.getClass()

    ARRAY01 = RC_FILES.split(",")
    ARRAY02 = VERSION_TAIL_0.split('.')

    ARRAY01.each {
        println("$it")
    }

    ARRAY02.each {
        println("$it")
    }
}

Expected output:

 

 

[Pipeline] echo
class java.lang.String 
[Pipeline] echo 
class java.lang.String
[Pipeline] echo
4
[Pipeline] echo
5
[Pipeline] echo
6
[Pipeline] echo
1
[Pipeline] echo
2
[Pipeline] echo
3

Current output:

 

 

[Pipeline] echo
class java.lang.String
[Pipeline] echo
class java.lang.String
[Pipeline] echo
4
[Pipeline] echo
5
[Pipeline] echo
6

 

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

rostergek@gmail.com (JIRA)

unread,
Jul 18, 2019, 10:09:01 AM7/18/19
to jenkinsc...@googlegroups.com
gek commented on Bug JENKINS-58552
 
Re: .split('.') method works incorrect

Oh, workaround was to use double backslashes:

script {
    RC_FILES = '4,5,6'
    println RC_FILES.getClass()

    VERSION_TAIL_0 = '1.2.3'
    println VERSION_TAIL_0.getClass()

    ARRAY01 = RC_FILES.split(",")
    ARRAY02 = VERSION_TAIL_0.split('\\.')

    ARRAY01.each {
        println("$it")
    }

    ARRAY02.each {
        println("$it")
    }
}

it was two wasted hours of my life...

Reply all
Reply to author
Forward
0 new messages