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

Pipeline: Using timestamps() breaks getLogMatcher()

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • Jenkins 2.60.1 with all plugins up to date.on 19th of July 2017

      The following code works without timestamps() and fails with. getLogMatcher() apparently

      fails to get the real log with timestamps() active.

       

      @NonCPS
      def setBuildName(manager, currentBuild) {
              def m = manager.getLogMatcher('stage (.*)')
              if (m?.matches()) {
                      currentBuild.displayName = m.group(1)
              } else {
                      currentBuild.displayName = 'NO MATCH'
              }
      }
      
      pipeline {
              agent {
                      label "master"
              }
              options {
                      // Just here for easy comment/uncomment of timestamp()    
                      buildDiscarder(logRotator(numToKeepStr: '5'))
                      // timestamps()
              }
      
              stages {
                      stage('checkout') {
                              steps {
                                      sh "echo 'stage checkout"
                              }
                      }
                      
                      stage("preparation") {
                              steps {
                                      sh "echo 'stage preparation'"
                              }
                      }
      
                      stage("install") {
                              steps {
                                      script {
                                              setBuildName(manager, currentBuild)
                                      }
                              }
                      }
              }
      }
      

       

          [JENKINS-45683] Pipeline: Using timestamps() breaks getLogMatcher()

          Michael jansen created issue -
          Jesse Glick made changes -
          Component/s Original: pipeline [ 21692 ]
          Labels New: pipeline
          Michael jansen made changes -
          Description Original: The following code works without timestamps() and fails with. getLogMatcher() apparently

          fails to get the real log with timestamps() active.

           

          {{@NonCPS}}
          {{def setBuildName(manager, currentBuild) \{}}
          {{ def m = manager.getLogMatcher('stage (.*)')}}
          {{ if (m?.matches()) \{}}
          {{ currentBuild.displayName = m.group(1)}}
          {{ } else \{}}
          {{ currentBuild.displayName = 'NO MATCH'}}
          {{ }}}
          {{}}}{{pipeline \{}}
          {{ agent \{}}
          {{ label "master"}}
          {{ }}}{{options \{}}
          {{ buildDiscarder(logRotator(numToKeepStr: '5'))}}
          {{ // timestamps()}}
          {{ }}}{{stages \{}}
          {{ stage('checkout') \{}}
          {{ steps \{}}
          {{sh "echo 'stage checkout"}}{{}}}
          {{ }}}
          {{ stage("preparation") \{}}
          {{ steps \{}}
          {{ sh "echo 'stage preparation'"}}
          {{ }}}
          {{ }}}{{stage("build") \{}}
          {{ steps \{}}
          {{ sh "echo 'stage build'"}}{{script \{}}
          {{ manager.listener.logger.println('Hello World')}}
          {{ }}}
          {{ }}}
          {{ }}}
          {{ stage("install") \{}}
          {{ steps \{}}
          {{ script \{}}
          {{ setBuildName(manager, currentBuild)}}
          {{ }}}
          {{ sh "echo 'stage install'"}}
          {{ }}}
          {{ }}}
          {{ }}}
          {{}}}
          New: The following code works without timestamps() and fails with. getLogMatcher() apparently

          fails to get the real log with timestamps() active.

           {CODE}
          @NonCPS
          def setBuildName(manager, currentBuild) {
                  def m = manager.getLogMatcher('stage (.*)')
                  if (m?.matches()) {
                          currentBuild.displayName = m.group(1)
                  } else {
                          currentBuild.displayName = 'NO MATCH'
                  }
          }

          pipeline {
                  agent {
                          label "master"
                  }
                  options {
                          // Just here for easy comment/uncomment of timestamp()
                          buildDiscarder(logRotator(numToKeepStr: '5'))
                          // timestamps()
                  }

                  stages {
                          stage('checkout') {
                                  steps {
                                          sh "echo 'stage checkout"
                                  }
                          }
                          
                          stage("preparation") {
                                  steps {
                                          sh "echo 'stage preparation'"
                                  }
                          }

                          stage("install") {
                                  steps {
                                          script {
                                                  setBuildName(manager, currentBuild)
                                          }
                                  }
                          }
                  }
          }
          {CODE}

           
          Jesse Glick made changes -
          Component/s New: groovy-postbuild-plugin [ 15685 ]
          Component/s Original: timestamper-plugin [ 15749 ]
          Steven G Brown made changes -
          Link New: This issue is related to JENKINS-39079 [ JENKINS-39079 ]
          Steven G Brown made changes -
          Assignee Original: Steven G Brown [ stevengbrown ] New: Stefan Wolf [ wolfs ]
          Stefan Wolf made changes -
          Assignee Original: Stefan Wolf [ wolfs ]

            Unassigned Unassigned
            jansenm Michael jansen
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: