Skip to content

Draft: Add timestamp parsing to jog log viewer

Miguel Rincon requested to merge 465350-show-timestamps-in-new-rendered into master

What does this MR do and why?

Adds compatibility with runner logs that have been generated with FF_TIMESTAMPS.

It parses and displays the log timestamp when found.

Changelog: added

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Before After
image image

How to set up and validate locally

  1. Ensure you are running an update version of gitlab-runner
  2. Create a pipeline that uses FF_TIMESTAMPS: "true"
  3. Run a job
  4. While viewing the job, add /viewer to go to the viewer. (e.g. http://gdk.test:3000/my-group/logs-timestamps/-/jobs/1924/viewer)

This is a FF_TIMESTAMPS: "true" pipeline I use to test 👇 :

Click to expand
variables:
  FF_TIMESTAMPS: "true"
  FF_SCRIPT_SECTIONS: "true" # this will allow you to collapse arbitrary scripts in the log

stages:
  - build

simple-job:
  stage: build
  script:
    - echo 'A simple command'

styled-job:
  stage: build
  before_script:
    - TXT_RED="\033[31m" && TXT_CLEAR="\033[0m"
  script:
    - echo -e "${TXT_RED}This is a long line of text, and this text is red, and this text is red, and this text is red,${TXT_CLEAR} but this part isn't${TXT_RED} however this part is red once more in this long line."
    - echo "This text is not colored"


# A multi-line command that should be collapsible
multi-line-command-job:
  stage: build
  script:
    - |
      echo "{
        'test': 'data',
        'test2': 'data2',
      }"
    - |
      echo "{
        'test': 'data',
        'test2': 'data2',
      }"

# This jobs helps me test long running jobs with many lines that gets cancelled
# You'll have to cancel this job manually to truncate it.
long-running-job:
  stage: build
  script:
    - while sleep 1; do date; done

# A job that triggers "Showing last 500.04 KiB of log" at the top for being too long
showing-last-job:
  stage: build
  script:
    - for i in {1..500}; do echo "This is a long line that gets repeated many many many many many many many many many many many many times $i"; done
    - for i in {1..500}; do echo "This is a long line that gets repeated many many many many many many many many many many many many times $i"; done
    - for i in {1..500}; do echo "This is a long line that gets repeated many many many many many many many many many many many many times $i"; done
    - for i in {1..500}; do echo "This is a long line that gets repeated many many many many many many many many many many many many times $i"; done
    - for i in {1..500}; do echo "This is a long line that gets repeated many many many many many many many many many many many many times $i"; done
    - for i in {1..500}; do echo "This is a long line that gets repeated many many many many many many many many many many many many times $i"; done
    - for i in {1..500}; do echo "This is a long line that gets repeated many many many many many many many many many many many many times $i"; done
    - for i in {1..500}; do echo "This is a long line that gets repeated many many many many many many many many many many many many times $i"; done
    - for i in {1..500}; do echo "This is a long line that gets repeated many many many many many many many many many many many many times $i"; done
    - for i in {1..500}; do echo "This is a long line that gets repeated many many many many many many many many many many many many times $i"; done

collapsible_job_single:
  variables:
    FF_SCRIPT_SECTIONS: "false"
  stage: build
  script:
    - echo -e "\033[0Ksection_start:`date +%s`:my_first_section\r\033[0KHeader of the 1st collapsible section"
    - echo 'this line should be hidden when collapsed'
    - echo -e "\033[0Ksection_end:`date +%s`:my_first_section\r\033[0K"

collapsible_job_multiple:
  variables:
    FF_SCRIPT_SECTIONS: "false"
  stage: build
  script:
    - echo -e "\033[0Ksection_start:`date +%s`:my_first_section\r\033[0KHeader of the 1st collapsible section"
    - echo 'this line should be hidden when collapsed'
    - echo -e "\033[0Ksection_start:`date +%s`:second_section\r\033[0KHeader of the 2nd collapsible section"
    - echo 'this line should be hidden when collapsed'
    - echo -e "\033[0Ksection_end:`date +%s`:second_section\r\033[0K"
    - echo -e "\033[0Ksection_end:`date +%s`:my_first_section\r\033[0K"

Related to #465350

Edited by Miguel Rincon

Merge request reports