Proper usage of Groovy Plug's ''?

Hello there,

I am somewhat lost here and maybe some one can help: I have the GroovyPlug plugin installed properly (at least it works perfectly fine for build read/write locks), but I want to use its '' in labels that are applied to the sources after a successful build. What exactly do I have to put in the 'Labeling pattern:' field under a config's VCS Settings tab in order to get labels in the format of 'abc-06-08-2010'?

Cheers and thanks,



With labeling pattern like "" you should be able to get the date into the label but in different format.
To change the format of from 20100806 to 06-08-2010 you should probably change a line in file
parameters.addEnvAndSystem("", (new SimpleDateFormat("yyyyMMdd")).format(buildStartTime));
parameters.addEnvAndSystem("", (new SimpleDateFormat("dd-MM-yyyy")).format(buildStartTime));
and run a new build to see how it works.


Hrm... I am using '' in the Label pattern field but I get the following error after a successful build:

jetbrains.buildServer.ParametersResolvingFailedException:  Cannot resolve values for some of the specified references: at  jetbrains.buildServer.vcs.impl.VcsLabeler.getLabelText( at  jetbrains.buildServer.vcs.impl.VcsLabeler.prepareLabel( at  jetbrains.buildServer.vcs.impl.VcsLabeler.access$200( at  jetbrains.buildServer.vcs.impl.VcsLabeler$3.buildFinished( at  sun.reflect.GeneratedMethodAccessor228.invoke(Unknown Source) at  sun.reflect.DelegatingMethodAccessorImpl.invoke(  at java.lang.reflect.Method.invoke( at  jetbrains.buildServer.util.EventDispatcher.dispatch( at  jetbrains.buildServer.serverSide.ServerSideEventDispatcher.access$000(  at  jetbrains.buildServer.serverSide.ServerSideEventDispatcher$1$  at  jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl$  at  jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl.runAs(  at  jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl.runAs(  at  jetbrains.buildServer.serverSide.impl.auth.SecurityContextImpl.runAsSystem(  at  jetbrains.buildServer.serverSide.ServerSideEventDispatcher$1.invoke(  at $Proxy599.buildFinished(Unknown Source) at  jetbrains.buildServer.serverSide.impl.BuildServerImpl.finishBuild(  at  jetbrains.buildServer.serverSide.impl.BuildServerImpl$  at java.util.concurrent.Executors$ at  java.util.concurrent.FutureTask$Sync.innerRun( at at  java.util.concurrent.ThreadPoolExecutor$Worker.runTask(  at  java.util.concurrent.ThreadPoolExecutor$  at


What TeamCity version do you use?
If you define a property with value "", does it get correct value in the build (you will probably need to dump properties in the build to see the value)?



it's 5.1.3. Ok now I created system property and set the vcs settings to the ones below. Now a label named 'rfit' is appended (sans date in it) :\



The 'GroovyPropertiesProvider.groovy' file looks like this now:

 * Copyright 2000-2009 JetBrains s.r.o.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
package jetbrains.buildserver.groovyPlug;

import com.intellij.openapi.diagnostic.Logger
import java.text.SimpleDateFormat
import jetbrains.buildServer.serverSide.SBuild
import jetbrains.buildServer.serverSide.SBuildType
import jetbrains.buildServer.serverSide.parameters.AbstractBuildParametersProvider
import jetbrains.buildServer.util.StringUtil
import jetbrains.buildServer.vcs.SVcsModification
import jetbrains.buildServer.vcs.SVcsRoot
import jetbrains.buildServer.vcs.VcsRootEntry
import org.jetbrains.annotations.NotNull
import org.jetbrains.annotations.Nullable

 * @author Yegor.Yarko
 *         Date: 04.03.2009
public class GroovyPropertiesProvider extends AbstractBuildParametersProvider {
  private static final Logger LOG = Logger.getInstance(GroovyPropertiesProvider.class.getName());

  DataUtil dataProvider;

  GroovyPropertiesProvider() {"GroovyPropertiesProvider initialized.");

  public Map getParameters(@NotNull final SBuild build, final boolean emulationMode) {
    LOG.debug("Processing build: " + build);
    final BuildParameters parameters = new BuildParameters();
    try {
      addBuildStartTime(parameters, build);
      addRunParameters(parameters, build);
      addTriggeredBy(parameters, build, emulationMode);
      addLastModificationsRevisions(parameters, build);
    } catch (Exception e) {
      LOG.error("Critical error occurred during parameters calculation", e);
    LOG.debug("Finished processing build: " + build);
    return parameters.getParameters();

  private void addRunParameters(@NotNull final BuildParameters parameters, @NotNull final SBuild build) {
    SBuildType buildType = build.getBuildType();
    if (buildType == null) return;

    for (Map.Entry runParameter: buildType.getRunParameters().entrySet()) {
      parameters.addConfiguration("runParam." + runParameter.getKey(), runParameter.getValue());

  void addBuildStartTime(@NotNull final BuildParameters parameters, SBuild build) {
    Date buildStartTime = build.getStartDate();
    parameters.addEnvAndSystem("", (new SimpleDateFormat("dd-MM-yyyy")).format(buildStartTime));
    parameters.addEnvAndSystem("build.start.time", (new SimpleDateFormat("HHmmss")).format(buildStartTime));

  void addTriggeredBy(@NotNull final BuildParameters parameters, SBuild build, final boolean emulationMode) {
    if (build.getTriggeredBy().getUser() != null) {
      parameters.addConfiguration("build.triggeredBy.username", build.getTriggeredBy().getUser().getUsername());
    }else if (emulationMode){
      parameters.addConfiguration("build.triggeredBy.username", "n/a");
    parameters.addConfiguration("build.triggeredBy", build.getTriggeredBy().getAsString());

  void addLastModificationsRevisions(@NotNull final BuildParameters parameters, SBuild build) {
    final Map rootVersions = dataProvider.getLastModificationsRevisions(build);

    for (VcsRootEntry rootEntry: build.getVcsRootEntries()){
      SVcsRoot root = (SVcsRoot)rootEntry.getVcsRoot()
      addModificationParams(parameters, root, rootVersions.get(root));
    if (build.getVcsRootEntries().size() == 1) {
      if (rootVersions.size() == 1) {
        addModificationParams(parameters, null, rootVersions.entrySet().iterator().next().getValue());
        addModificationParams(parameters, null, null);

  private def addModificationParams(BuildParameters parameters, @Nullable SVcsRoot root, @Nullable SVcsModification modification) {
    String suffix = root == null ? "" : "." + StringUtil.replaceNonAlphaNumericChars(root.getName(), (char) '_');
    parameters.addEnvAndSystem("build.vcs.lastIncluded.revision" + suffix, getVersion(modification));
    parameters.addEnvAndSystem("build.vcs.lastIncluded.timestamp" + suffix, getDate(modification))

  private @NotNull String getDate(@Nullable SVcsModification modification) {
    if (modification != null) {
      return (new SimpleDateFormat("yyyyMMdd'T'HHmmssZ")).format(modification.getVcsDate())

  private @NotNull  String getVersion(@Nullable SVcsModification modification) {
    if (modification == null){
      return "";
    String version = modification.getDisplayVersion()
    if (version == null) {
      version = modification.getVersion();
    return version;

So why is no date appended?




> So why is no date appended?
Because you've created a property with the same name. I meant _value_, not _name_.

Please remove "" property from the Parameters section of the build configuration web UI.
You can add "test" property then set it to and check what the value is inside the build script.



ok I removed the old one and created a new one named 'BuildDate' (see below), used that in the VCS setting (see 2nd picture), but now when triggering a build i get the message saying 'Warning: No enabled compatible agents for this build configuration. Please register a build agent or tweak build configuration requirements.'?






You can see why the build configuration is considered not compatible on the Agent Requirements tab.

So far looks like an issue with groovyPlug plugin installation. Can you make sure you have the plugin unmodified by backuping/deleting .BuildServer\config\__groovyPlug__ directory and reinstalling the plugin from the most recent version?



I did, but still get the incompatible client error. Removed the __groovyPlug__ folder, replaced (even though it was the same version from april 16th 2010), restarted tomcat.. the folder was recreated, but I still get this:





Cannot reproduce this so far.

You can try to add the lines:

  <category name="jetbrains.buildserver.groovyPlug">
    <priority value="DEBUG"/>
    <appender-ref ref="ROLL"/>

into conf\teamcity-server-log4j.xml file and restart the server.

Then try to run unrelated build and look for logging like:
[2010-08-11 16:12:28,736]  DEBUG - ver.groovyPlug.BuildParameters - Adding system property '' with value =20100811

If you cannot figure out what is wrong, please attach the full logs.


Please sign in to leave a comment.