Skip to content
GitLab
Next
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    Projects Groups Topics Snippets
  • Register
  • Sign in
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 51,047
    • Issues 51,047
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1,562
    • Merge requests 1,562
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLabGitLab
  • Issues
  • #22901
Closed
Open
Issue created Jun 21, 2018 by Ghost User@ghost1Contributor

New predefined variables for job start time and pipeline created time

Release notes

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_JOB_STARTED_AT and CI_PIPELINE_CREATED_AT, provided in ISO 8601 format and UTC time zone.

Thanks to @Winkies for this contribution!

https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#predefined-variables-reference

Problem to solve

We need a reliable UTC and ISO-8601 compliant date/timestamp indicating the start of a CI job.

Further details

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:

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 😄

Proposal

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...

  • CI_JOB_TIMESTAMP
  • or CI_JOB_STARTED

Links / references

Edited Mar 15, 2021 by Thao Yeager
Assignee
Assign to
Time tracking