Child pages
  • Date Build Number

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

General Info


Xavier Seignard


free, open-source


Wiki Markup

Date Plugin


A stupid simple plugin that allow you to use the pattern {date} in your build number in order to get the current date. The plugin works well, but improving it would be a good idea.

Furthermore, it a good start to see how to create plugins.

Here is the

Code Block


import java.text.SimpleDateFormat;
import java.util.Date;

import jetbrains.buildServer.serverSide.BuildServerAdapter;
import jetbrains.buildServer.serverSide.SBuildServer;
import jetbrains.buildServer.serverSide.SRunningBuild;

import com.intellij.openapi.diagnostic.Logger;

public class DateBuildNumber extends BuildServerAdapter
   private final static Logger LOG = Logger.getInstance(DateBuildNumber.class.getName());
   private static final String DATE = "{date}"; 
   // Constructor
   public DateBuildNumber(SBuildServer aBuildServer)
       System.out.println( "### DateBuildNumber adding listener=" + this );

Under construction

("### DateBuildNumber adding listener=" + this);

       // Register with TC

   public void buildStarted(SRunningBuild build)
       String buildNumber = build.getBuildNumber();
       // Logging in "teamcity_install_dir\logs\stdout_XXXX.log"
       System.out.println("### DateBuildNumber plugin : buildStarted");"### DateBuildNumber plugin : buildStarted");
       // If the build number contains the DATE = "{date}" pattern we replace it by the current date.
       if(buildNumber.lastIndexOf(DATE) > -1)
           build.setBuildNumber(buildNumber.replace(DATE, createBuildNumber()));
           System.out.println("### DateBuildNumber plugin, no {date} pattern found");
 "### DateBuildNumber plugin, no {date} pattern found");

   public String createBuildNumber()
       Date currentBuild = new Date();
       // Here you can modify the date format
       // Please refer to the javaDoc :
       SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yy-HH'h'mm");
       return sdf.format(currentBuild);

And the build-server-plugin.xml :

Code Block

<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="constructor">
  <bean id="date" class=""/>

See Also

forum topic