Skip to main content

Date Variables

The Date Variables plugin provides the date and time as parameters in TeamCity builds. The individual components can be used in build configurations, for example for build numbers, versions or naming artifacts. The plugin is ready to use right after installation and requires no configuration.

How It Works​

The plugin registers a parameter provider on the TeamCity server that adds the following parameters to every build. The values are determined on the server at the moment TeamCity resolves the parameters of the build, and follow the time zone of the TeamCity server — not that of the agent. They therefore reflect the time of the build, not the time of the commit.

ParameterDescriptionExample
teamcity.date.yearYear2023
teamcity.date.monthMonth, zero-padded05
teamcity.date.dayDay of the month, zero-padded17
teamcity.date.hourHour in 24h format, zero-padded14
teamcity.date.minuteMinute, zero-padded30
teamcity.date.secondSecond, zero-padded45
teamcity.date.timestampUnix timestamp in seconds1684331445
teamcity.date.isoDate and time in ISO 8601 format2023-05-17T14:30:45+02:00

Installation​

Requirements:

  • TeamCity 2025.03 or later
  • Java 8 or later

Installation:

  1. Download the latest release from the JetBrains Marketplace
  2. Open the TeamCity administration and navigate to Plugins
  3. Click Upload plugin zip and select the downloaded ZIP file
  4. Restart the TeamCity server

Usage​

The parameters are referenced with percent signs like all TeamCity parameters, for example %teamcity.date.year%. No configuration in the project or the build configuration is required.

Build number with date:

%build.counter%.%teamcity.date.year%%teamcity.date.month%%teamcity.date.day%

Results in 42.20230517, for example.

In a command line step:

echo "Build created on %teamcity.date.year%-%teamcity.date.month%-%teamcity.date.day% at %teamcity.date.hour%:%teamcity.date.minute%"

Artifact name with timestamp:

release-%teamcity.date.timestamp%.zip

As an environment variable in the build process:

The parameters are configuration parameters. They are replaced in the TeamCity settings but not passed to the build process as environment variables automatically. To do so, add a parameter of your own to the build configuration:

NameValue
env.BUILD_DATE%teamcity.date.iso%

The value is then available in the build process as the environment variable BUILD_DATE.

Notes​

  • The time zone cannot be configured in the plugin. The time zone of the operating system or the JVM of the TeamCity server is used.
  • The offset in teamcity.date.iso (for example +02:00) indicates the time zone used and takes daylight saving time into account.
  • teamcity.date.timestamp is independent of the time zone.