Wednesday, June 26, 2019

Date or Timestamp variable in Jenkins

To get jenkins environment variable to be created: $BUILD_TIMESTAMP, we need to have the below plugin installed.

Plugin: Build Timestamp Plugin

Configure

BUILD_TIMESTAMP exported by default, and you can add more variables with different format patterns in Global Configure page.

Daylight Saving Time

DST is not enabled by default.
If your location uses DST, you can enable it by setting the timezone to the correct city such as America/New_York.
For India: Asia/Kolkata

Using timestamps in Maven/Gradle/Shell

They are available in Maven build and Gradle build as built-in properties/variables as well.
Maven:
As defined property in pom, equals to
System.getProperty('BUILD_TIMESTAMP')
Gradle:
System.getenv('BUILD_TIMESTAMP')
Shell:
"$BUILD_TIMESTAMP"
Reference: Link1 Link2

No comments:

Post a Comment