Jenkins : Timestamper

Adds timestamps to the Console Output.

Plugin Information

View Timestamper on the plugin site for more information.

Older versions of this plugin may not be safe to use. Please review the following warnings before using an older version:

Example output:

21:51:15  Started by user anonymous
21:51:15  Building on master
21:51:17  Finished: SUCCESS

Instructions: Freestyle

Enable timestamps within the "Build Environment" section of the build's configuration page.

To enable timestamps for multiple builds at once, use the Configuration Slicing Plugin version 1.32 or later.

Instructions: Pipeline Builds

Since Timestamper 1.9

Set the global option to enable timestamps for all Pipeline builds, or use the step as described below.

Since Timestamper 1.8

Use the timestamps step to wrap the rest of the pipeline script.

timestamps {
    // some block
}

Since Timestamper 1.7

Prior to Timestamper 1.8, timestamps can only be recorded within a node.

node {
    wrap([$class: 'TimestamperBuildWrapper']) {
        echo 'hello from Workflow'
    }
}

Customization

  • The timestamp format can be configured via the Configure System page.
  • There is a panel on the left-hand side of the console page which allows either the system clock time or the elapsed time to be displayed.
  • The time zone used to display the timestamps can be configured by setting a system parameter as described here: Change time zone.

Scripting

Scripts can read the timestamps from the /timestamps/ URL of each build.

Examples:

  • /timestamps/
    By default, display the elapsed time in seconds with three places after the decimal point.
  • /timestamps/?time=HH:mm:ss&appendLog
    Display the system clock time and append the line from the log.
  • /timestamps/?elapsed=HH:mm:ss.S&appendLog
    Display the elapsed time and append the line from the log.
  • /timestamps/?time=HH:mm:ss&elapsed=HH:mm:ss.S
    Display both the system clock time and the elapsed time.
  • /timestamps/?currentTime&time=HH:mm:ss
    Display the current time on the Jenkins master.

Supported query parameters:

  • time (since 1.8)
    Display the system clock time. Accepts the JDK SimpleDateFormat format.
    The time zone and locale of the Jenkins server will be used, unless they are configured with the timeZone and locale query parameters.
  • elapsed (since 1.8)
    Display the elapsed time since the start of the build. Accepts the commons-lang DurationFormatUtils format.
  • precision (since 1.3.2)
    Display the elapsed time in seconds, with a certain number of places after the decimal point. Accepts a number of decimal places or values such as seconds and milliseconds.
  • appendLog (since 1.8)
    Display the console log line after the timestamp.
  • startLine (since 1.8)
    Display the timestamps starting from a certain line. Accepts a positive integer to start at that line, or a negative integer to start that many lines back from the end.
  • endLine (since 1.8)
    Display the timestamps ending at a certain line. Accepts a positive integer to finish at that line, or a negative integer to finish that many lines back from the end.
  • timeZone (since 1.8)
    Time zone used when displaying the system clock time. Accepts the JDK TimeZone ID format.
  • locale (since 1.8)
    Select the locale to use when displaying the system clock time. Accepts a locale in the format recognised by commons-lang LocaleUtils.toLocale.
  • currentTime (since 1.8.8)
    Display the current time on the Jenkins master instead of reading timestamps from the build.

Reading the timestamps directly from the file system is not recommended, because the format may change.

Java API

Since Timestamper 1.8

Other plugins can add a dependency on the Timestamper plugin, and then use the TimestamperAPI.read method to retrieve the timestamps.
The read method accepts any query string that can be passed to the /timestamps/ URL.

String query = "time=HH:mm:ss";
try (BufferedReader reader = TimestamperAPI.get().read(build, query)) {
    // read timestamps here
}

Release History

New releases may take a few hours to appear in the update center.

1.10 and newer

See the GitHub release page.

1.9 (2019-02-07)

  • Redesign of integration with Pipeline: timestamps are now written in plain text into the build log, and displayed specially if and when viewed in the classic UI. Also the timestamps step/option may be omitted in favor of a global option. Solves  JENKINS-48344 - Log files generated by Jenkins pipeline scripts are bloated Resolved JENKINS-54081 - Timestamps missing for agent-based steps in Pipeline Job 2.26 Resolved , and (for pre-2.161 Jenkins versions)  JENKINS-55257 - Timestamper break builds on Windows agents Resolved .

1.8.10 (May 9, 2018)

  • Add a forward slash to the URLs opened when clicking "View as plain text". For some web servers, this is necessary to open the correct page. (JENKINS-50713)
  • Hide the "View as plain text" link when viewing a pipeline step because it isn't applicable to this page. (JENKINS-47051)
  • Fix the display of timestamps at the /timestamps/ URL for pipeline builds when not using the appendLog flag. (JENKINS-51106)
  • Use the browser's time zone by default. This only takes affect for new users or after clearing the cookies. (pull request #22)
    Contributed by Wilfred Hughes

1.8.9 (Dec 17, 2017)

  • Remove extra lines from /timestamps/ URL output when log file contains carriage return characters. (JENKINS-46420) (pull request #21)
    Contributed by Darragh Bailey

1.8.8 (Jan 22, 2017)

1.8.7 (Oct 05, 2016)

1.8.6 (Sep 19, 2016)

  • The timestamps are no longer affected by styles applied by the AnsiColor plugin. (JENKINS-34019) (reverted in next release 1.8.7)
  • Console page settings were not appearing for some users. (JENKINS-38085)
  • Prevent unnecessary warning messages from being logged with Timestamper 1.8.5 installed. (JENKINS-38098)

1.8.5 (Aug 31, 2016)

  • Performance: Read from end of log file for finished build (pull request #18)
    Contributed by Akbashev Alexander
  • Improve error reporting when invalid parameters are passed to the /timestamps URL.
  • Requires Java 7 or later.

1.8.4 (Jun 26, 2016)

  • When reading the log file, handle escape characters that do not form part of a console note. (JENKINS-36103)

1.8.3 (Jun 12, 2016)

  • Allow running behind an HTTPS proxy. (JENKINS-35315)
  • Prevent warning messages when workflow-step-api is not installed. (JENKINS-35375)

1.8.2 (May 15, 2016)

  • Make the workflow-step-api dependency optional.

1.8.1 (May 15, 2016)

  • Custom pipeline step for recording timestamps. (JENKINS-30142)
  • Display a link to the raw console output including timestamps. (JENKINS-26794)
  • New query parameters recognised by the /timestamps/ URL: time, elapsed, appendLog, startLine, endLine, timeZone, locale.
  • Java API for retrieving timestamps from other plugins. (JENKINS-21213)
  • The elapsed time is measured from the actual build start time, rather than the scheduled start time.

1.8 (May 15, 2016)

1.7.4 (Jan 31, 2016)

1.7.3 (Jan 13, 2016)

  • Persist the chosen timestamp display settings. This was broken since 1.7.2. (JENKINS-32074)

1.7.2 (Aug 15, 2015)

  • Change cookie path from '/' to the root URL of Jenkins (JENKINS-29899)
    Contributed by Kiyoshi Ohgishi

1.7.1 (Jul 11, 2015)

  • Display the console page settings within the side panel with the other actions. (JENKINS-28948)
  • Support for newer Jenkins to display the settings in the console page. (JENKINS-29361)

1.7 (Jun 24, 2015)

1.6.2 (May 31, 2015)

1.6.1 (May 27, 2015)

1.6 (Mar 11, 2015)

  • Add an option to use the browser's time zone. (pull request #11)
    Contributed by michael1010
  • Japanese translations. (pull request #12)
    Contributed by Pei-Tang Huang

1.5.16 (Feb 25, 2015)

  • Allow clicking on the text labels next to the radio buttons. (JENKINS-27054)
    Contributed by Paul Fee

1.5.15 (Dec 24, 2014)

  • Fix encoding problem with the German translation of the plugin description. (JENKINS-26206)

1.5.14 (Jul 30, 2014)

  • Reduce size of the X-ConsoleAnnotator HTTP header. (JENKINS-23867)
    The header size may have caused problems depending on how your web container is configured.

1.5.13 (Jul 23, 2014)

1.5.12 (Jun 07, 2014)

  • Allow the time zone for the timestamps to be configured. (JENKINS-22586)

1.5.11 (Apr 09, 2014)

1.5.10 (Apr 09, 2014)

1.5.9 (Mar 10, 2014)

1.5.8 (Jan 02, 2014)

  • Implemented a work-around for servers that do not reliably report the elapsed time. (JENKINS-19778)
  • Support for gzipped build logs.
  • Requires Java 6 or later.
  • Requires Jenkins 1.520.

1.5.7 (Aug 21, 2013)

  • Fix minor incompatibility with Publish Over SSH Plugin. (JENKINS-19193)

1.5.6 (Jul 25, 2013)

  • Update the DurationFormatUtils URL in the help messages. (pull request #4)
    Contributed by Bananeweizen

1.5.5 (Jul 24, 2013)

  • Display timestamps correctly when viewing the truncated console log. (JENKINS-17779)
    Contributed by Kohsuke Kawaguchi

1.5.4 (Jun 04, 2013)

1.5.3 (Mar 17, 2013)

  • Traditional Chinese translations. (pull request #2)
    Contributed by Pei-Tang Huang
  • Workaround a bug in Jenkins which causes a VM crash. (JENKINS-16528)
  • Prevent an NPE being thrown when the slave is taken offline during a build. (JENKINS-16778)

1.5.2 (Feb 03, 2013)

1.5.1 (Jan 22, 2013)

1.5 (Jan 05, 2013)

  • Can choose to display either the system clock time, the elapsed time since the build started, or no timestamps at all. (JENKINS-14931)
  • The elapsed time format can be configured.

1.4 (Dec 27, 2012)

  • The timestamp data now requires less disk space and does not clutter the build log file. (JENKINS-14932)
    Upgrade warning:
    If you use a script to read the timestamp data directly from the build log file, you will need to either:
    (a) Modify the script to read from the /timestamps URL instead (recommended) OR
    (b) Provide the -Dtimestamper-consolenotes=true VM argument when starting Jenkins to use the old format.

1.3.2 (Sep 30, 2012)

  • Scripts can read timestamps from the /timestamps URL of each build.
  • Requires Jenkins 1.461.

1.3.1 (Sep 08, 2012)

  • Can configure an empty timestamp format.

1.3 (Aug 26, 2012)

  • The timestamp format is configurable. (pull request #1)
    Contributed by Frederik Fromm
  • Requires Jenkins 1.450.

1.2.2 (Feb 07, 2011)

  • Built from github repository with new Jenkins infrastructure. No behavioural changes.

1.2.1 (Sep 07, 2010)

  • Timestamps no longer interfere with the Ant target highlighting.

1.2 (Aug 29, 2010)

  • More robust implementation; prevents errors that could arise for some build configurations. (JENKINS-7112)
  • Requires Jenkins 1.374.

1.1 (Aug 01, 2010)

1.0 (Jul 31, 2010)

  • Initial release.
  • Requires Jenkins 1.349.

Attachments:

with.png (image/png)
without.png (image/png)