CruiseControl.NET: using $(CCNetLabel ) inside ccnet.config file

When calling external processes like MSBuild cruise control sets environment variables. One of values is CCNetLabel. it holds the value of the current projects label. I want to use the same values in ccnet config itself but when I try ccnet config has a problem. I get the following error:

[CCNet Server:ERROR] INTERNAL ERROR: Reference to unknown symbol CCNetLabel
ThoughtWorks.CruiseControl.Core.Config.Preprocessor.EvaluationException: Reference to unknown symbol CCNetLabel
at ThoughtWorks.CruiseControl.Core.Config.Preprocessor.ConfigPreprocessorEnvironment._GetConstantDef(String name)
at ThoughtWorks.CruiseControl.Core.Config.Preprocessor.ConfigPreprocessorEnvironment.eval_text_constant(String name)



I actually want to append the CCNetLabel to another variable so I need to access the property in ccnet.config.

is there a different way to reference these variables?

13.10.2009 22:43:00

There is no way of accessing these environment variables inside CCNET configuration. I think almost anybody who configured CCNET (including myself) has tried to do so. This feature has been requested often, but it hasn't been implemented yet.

If you want access to CCNetWorkingDirectory or CCNetArtifactDirectory there is a workaround:

<cb:define name="project.workingDirectory">c:/foo</cb:define>
<cb:define name="project.artifactDirectory">c:/bar</cb:define>

But I'm not aware of a solution for accessing CCNetLabel. Sorry, I don't have better news.

14.10.2009 06:57:38

The following articles should be able to help you. You may be able to use cb:scope, or defining your whole project in a cb:define and pass the project name in.

-Good luck-

10.05.2010 07:52:21

The following can be used in config file in ccnet version 1.5 < cb:define buildversion="$[$CCNetLabel]" />

11.05.2010 15:59:22
This works. I put this one after the labeller type. and used $(buildversion) and it got substituted correctly.
Pradeep 4.03.2010 13:46:44

We had a need to do this too, and found that we could use Replacement Dynamic Values, introduced in CruiseControl.NET 1.5, to access the CCNetLabel from within ccnet.config.

For example, the dynamicValues block in this snippet:

      <replacementValue property="publishDir">
          <namedValue name="$CCNetLabel" value="Default" />

Produces a publishDir path containing the CCNetLabel value on the fly:


(Note that for this particular example, useLabelSubDirectory is set to false to avoid appending the CCNetLabel to the publishDir path.)

7.08.2012 21:50:52

I tried to do this as well and just ended up using a NANT script, where I can get to CCNetLabel as an environment variabl like so:

  <property name="" value="${environment::get-variable('CCNetLabel')}"/>
10.05.2010 08:11:25

if using version 1.5 then you can directly specify $(CCNetLabel) in the msbuild task

 <buildArgs>/p:Configuration=Debug /p:Platform="Any Cpu" /p:AssemblyVersion=$(CCNetLabel) </buildArgs>
 <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>

8.07.2010 12:02:52

I think Darryl's answer is the best approach to solve this problem in CCNET 1.5. Just two comments about the answer:

  • This is the right link to ccnet docs about Dynamic Parameters.
  • As you can read in the docs, there is a shortcut to obtain just the value of the integration property you are looking for using the syntax $[$Integration_Property]. In your case, using $[$CCNetLabel] would work.
20.01.2011 15:01:37

I've solved this by adding an msbuild task in the publisher section (including the CCNetLabel in the path)

        <replacementValue property="buildArgs">
            <format>/noconsolelogger /v:quiet /p:Configuration=Release /p:WebProjectOutputDir=c:\Publish\WebApp\{0}\ /p:OutDir=c:\Publish\WebApp\{0}\bin\</format>
                <namedValue name="$CCNetLabel" value="Default" />
29.11.2012 23:21:30