Display timestamp in log lines
What does this MR do and why?
This change display the timestamp next to each log line if provided by the runner log.
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 |
---|---|
How to set up and validate locally
- Ensure you have an up to date runner (17.0 works).
- Enable the feature flag
parse_ci_job_timestamps
. - Enable
FF_TIMESTAMPS: "true"
in your.gitlab-ci.yml
file. (Runner feature flags are not like our Gitlab Feature flags!)
You can use this example (see the variables
entry):
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'
# 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"
- Run the pipeline, and check the logs.
Related to #455582 (closed)
Edited by Miguel Rincon