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.
| Parameter | Description | Example |
|---|---|---|
teamcity.date.year | Year | 2023 |
teamcity.date.month | Month, zero-padded | 05 |
teamcity.date.day | Day of the month, zero-padded | 17 |
teamcity.date.hour | Hour in 24h format, zero-padded | 14 |
teamcity.date.minute | Minute, zero-padded | 30 |
teamcity.date.second | Second, zero-padded | 45 |
teamcity.date.timestamp | Unix timestamp in seconds | 1684331445 |
teamcity.date.iso | Date and time in ISO 8601 format | 2023-05-17T14:30:45+02:00 |
Installation
Requirements:
- TeamCity 2025.03 or later
- Java 8 or later
Installation:
- Download the latest release from the JetBrains Marketplace
- Open the TeamCity administration and navigate to Plugins
- Click Upload plugin zip and select the downloaded ZIP file
- 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:
| Name | Value |
|---|---|
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.timestampis independent of the time zone.