New predefined variables for job start time and pipeline created time
Previously when you wanted to reference the date and time when a job started or a pipeline was created, you would need a script to retrieve these timestamps. Now they are readily available as predefined variables
CI_PIPELINE_CREATED_AT, provided in ISO 8601 format and UTC time zone.
Thanks to @Winkies for this contribution!
Problem to solve
We need a reliable UTC and ISO-8601 compliant date/timestamp indicating the start of a CI job.
Hopefully there are other use-cases. What prompted me to go looking and, ultimately, to propose this feature was trying to apply standard Docker image labels, specifically:
org.opencontainers.image.created ("date and time on which the image was built").
For the time being, I'm making a
date call in my
before_script: - export CI_JOB_TIMESTAMP=$(date --utc --iso-8601=seconds)
But, wait, these exact parameters for
date are valid on my machine, but not on the gitlab.com shared runners! I had to use a different form.
before_script: - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
OK, now, what happens when I also have Windows runners? Gah! That's why a nice timestamp from the runner would be lovely
Add CI_JOB_STARTED_AT and CI_PIPELINE_CREATED_AT as predefined variables.
What does success look like, and how can we measure that?
A new "predefined" environment variable. My suggestions are...