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

Pipeline: Using timestamps() breaks getLogMatcher()

    XMLWordPrintable

Details

    Description

      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)
                                      }
                              }
                      }
              }
      }
      

       

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick added a comment -

            Please fix formatting of your sample program, and specify what “fails” means.

            jglick Jesse Glick added a comment - Please fix formatting of your sample program, and specify what “fails” means.

            Fixed code. Failed means the LogMatcher doesn't match. With timestamp() the LogMatcher apparently sees a different log output.

            jansenm Michael jansen added a comment - Fixed code. Failed means the LogMatcher doesn't match. With timestamp() the LogMatcher apparently sees a different log output.
            jglick Jesse Glick added a comment -

            Right…because the lines are prefixed by timestamps.

            jglick Jesse Glick added a comment - Right…because the lines are prefixed by timestamps.
            jglick Jesse Glick added a comment -

            Would presumably also affect freestyle builds using the system property to keep timestamp annotations in the main build log, as opposed to a separate file.

             

            jglick Jesse Glick added a comment - Would presumably also affect freestyle builds using the system property to keep timestamp annotations in the main build log, as opposed to a separate file.  

            People

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

              Dates

                Created:
                Updated: