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

logs for individual workflow steps do not contain timestamps

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • jenkins 1.609.2
      workflow 1.10-beta1
      timestamper 1.7.2

      Consider the workflow that is stored in an SCM

          node('master') {
              wrap([$class: 'TimestamperBuildWrapper']) {
                  sh 'echo I woz here'
              }
          }
      

      if you view ${JOB_URL}/${BUILD_ID}/console

      then you will see timestamps for the echo step but not the SCM checkout.

      However if you view the logs for the individual step ${JOB_URL}/${BUILD_ID}/execution/node/3/log/ then the output is shown without any timestamps. This means that to check performance of an individual step you need to look at all of the logs which is a performance issue - and not user friendly.

          [JENKINS-30143] logs for individual workflow steps do not contain timestamps

          Jesse Glick added a comment -

          Strange, would need to debug why that is happening.

          Jesse Glick added a comment - Strange, would need to debug why that is happening.

          Andrew Bayer added a comment -

          Yeah, I noticed that with multibranch.

          Andrew Bayer added a comment - Yeah, I noticed that with multibranch.

          Andrew Bayer added a comment -

          Verified it's happening, I think it's something different with the Timestamper plugin behavior for step executions vs runs as a whole. I'm digging a bit.

          Andrew Bayer added a comment - Verified it's happening, I think it's something different with the Timestamper plugin behavior for step executions vs runs as a whole. I'm digging a bit.

          Andrew Bayer added a comment - Is it as simple as https://github.com/jenkinsci/timestamper-plugin/blob/master/src/main/java/hudson/plugins/timestamper/annotator/TimestampAnnotator.java#L77-L79?

          Steven G Brown added a comment - - edited

          TimestampAnnotator is used for freestyle or Maven jobs, but the pipeline jobs use TimestampNote:
          https://github.com/jenkinsci/timestamper-plugin/blob/0c20ac3/src/main/java/hudson/plugins/timestamper/TimestampNote.java#L99

          To display the elapsed timestamps, it needs to know when the build started, so it casts to Run then calls getTimeInMillis(). The Workflow plugin provides a StepAtomNode instead - so I think we need a way to get the build start time from the node. Perhaps we can add an interface to Jenkins core with a getRun method and have StepAtomNode implement it?

          Steven G Brown added a comment - - edited TimestampAnnotator is used for freestyle or Maven jobs, but the pipeline jobs use TimestampNote : https://github.com/jenkinsci/timestamper-plugin/blob/0c20ac3/src/main/java/hudson/plugins/timestamper/TimestampNote.java#L99 To display the elapsed timestamps, it needs to know when the build started, so it casts to Run then calls getTimeInMillis() . The Workflow plugin provides a StepAtomNode instead - so I think we need a way to get the build start time from the node. Perhaps we can add an interface to Jenkins core with a getRun method and have StepAtomNode implement it?

          On second thought, the Timestamper plugin could record the elapsed time in each TimestampNote. It doesn't seem to increase the size of the log files very much.

          Steven G Brown added a comment - On second thought, the Timestamper plugin could record the elapsed time in each TimestampNote . It doesn't seem to increase the size of the log files very much.

          Code changed in jenkins
          User: Steven Brown
          Path:
          src/main/java/hudson/plugins/timestamper/Timestamp.java
          src/main/java/hudson/plugins/timestamper/TimestampNote.java
          src/main/java/hudson/plugins/timestamper/TimestampNotesOutputStream.java
          src/main/java/hudson/plugins/timestamper/TimestamperBuildWrapper.java
          src/main/java/hudson/plugins/timestamper/format/TimestampFormatter.java
          src/test/java/hudson/plugins/timestamper/TimestampNoteTest.java
          src/test/java/hudson/plugins/timestamper/TimestampNotesOutputStreamTest.java
          src/test/java/hudson/plugins/timestamper/TimestampTest.java
          src/test/java/hudson/plugins/timestamper/action/TimestampsActionTest.java
          http://jenkins-ci.org/commit/timestamper-plugin/a7748486421c450d05288acde444c08ebe0c77d2
          Log:
          [FIXED JENKINS-30143] Store elapsed time in timestamp console notes

          The timestamp console notes previously relied on the context being a Run, so
          that they can get the build start time and use it to calculate the elapsed time.
          The elapsed time is now stored within the console notes during the build.

          This allows timestamps to be displayed when a different context type is
          provided, e.g. the workflow plugin provides a StepAtomNode.

          Builds that ran with an earlier version of Timestamper and an unrecognised
          context type will now display the system clock timestamps but not the elapsed
          timestamps, because that information was not recorded.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Steven Brown Path: src/main/java/hudson/plugins/timestamper/Timestamp.java src/main/java/hudson/plugins/timestamper/TimestampNote.java src/main/java/hudson/plugins/timestamper/TimestampNotesOutputStream.java src/main/java/hudson/plugins/timestamper/TimestamperBuildWrapper.java src/main/java/hudson/plugins/timestamper/format/TimestampFormatter.java src/test/java/hudson/plugins/timestamper/TimestampNoteTest.java src/test/java/hudson/plugins/timestamper/TimestampNotesOutputStreamTest.java src/test/java/hudson/plugins/timestamper/TimestampTest.java src/test/java/hudson/plugins/timestamper/action/TimestampsActionTest.java http://jenkins-ci.org/commit/timestamper-plugin/a7748486421c450d05288acde444c08ebe0c77d2 Log: [FIXED JENKINS-30143] Store elapsed time in timestamp console notes The timestamp console notes previously relied on the context being a Run, so that they can get the build start time and use it to calculate the elapsed time. The elapsed time is now stored within the console notes during the build. This allows timestamps to be displayed when a different context type is provided, e.g. the workflow plugin provides a StepAtomNode. Builds that ran with an earlier version of Timestamper and an unrecognised context type will now display the system clock timestamps but not the elapsed timestamps, because that information was not recorded.

          Released with Timestamper 1.7.4.

          Steven G Brown added a comment - Released with Timestamper 1.7.4.

          Sorin Sbarnea added a comment -

          Sorry for reopening this but it seem that the pipeline usage is not documented on the project homepage. Having is documented in side a bug it a fit away from ideal.

          Sorin Sbarnea added a comment - Sorry for reopening this but it seem that the pipeline usage is not documented on the project homepage. Having is documented in side a bug it a fit away from ideal.

          ssbarnea, please feel welcome to add anything that is missing to the wiki.

          Steven G Brown added a comment - ssbarnea , please feel welcome to add anything that is missing to the wiki.

            stevengbrown Steven G Brown
            teilo James Nord
            Votes:
            3 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: