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

regex matcher in a decarative pipeline script does not behave correctly

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Not A Defect
    • Component/s: pipeline
    • Labels:
    • Environment:
    • Similar Issues:

      Description

      Running the following Jenkins declarative pipeline job I would expect the output to be the same for each regular expression:

      Here is the content of the pipeline:

      pipeline{
      agent{ node{ label('master')}}
      stages{
      stage('RegEx'){
      steps{
      script{
      def m_ex
      def m_in
      stanza = '''Hello.
      how are you doing?
      It is a nice day.
      Are we there yet?'''
      m_ex = stanza =~ /(m?).nice./
      if (m_ex){
      println "Found: ${m_ex[0][0]}"
      }else

      { println "m_ex did not return a match. Why?" }

      if ((m_in = stanza =~ /(m?).nice./)){
      println "Found: ${m_in[0][0]}"
      }else

      { println "m_in did not return a match. Why?" }

      println GroovySystem.version
      }
      }
      }
      }

      Here is the result:

      Running in Durability level: MAX_SURVIVABILITY
      [Pipeline] Start of Pipeline
      [Pipeline] node
      Running on Jenkins in /var/lib/jenkins/workspace/Test/RegularExpression
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (RegEx)
      [Pipeline] script
      [Pipeline]

      { [Pipeline] echo Found: It is a nice day. [Pipeline] echo m_in did not return a match. Why? [Pipeline] echo 2.4.12 [Pipeline] }

      [Pipeline] // script
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS

        Attachments

          Activity

          Hide
          jhutton Jeff Hutton added a comment -

          Sorry. I got the syntax wrong.

          Ignore.

          • Jeff Hutton
          Show
          jhutton Jeff Hutton added a comment - Sorry. I got the syntax wrong. Ignore. Jeff Hutton

            People

            • Assignee:
              jhutton Jeff Hutton
              Reporter:
              jhutton Jeff Hutton
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: