Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58552

.split('.') method works incorrect

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: groovy-plugin, pipeline
    • Labels:
      None
    • Environment:
      Jenkins 2.164.1
      Pipeline:groovy 2.70
    • Similar Issues:

      Description

       

      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
      

       

        Attachments

          Activity

          Hide
          gek gek added a comment -

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

          Show
          gek gek added a comment - 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...

            People

            • Assignee:
              vjuranek vjuranek
              Reporter:
              gek gek
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: