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

ccnet-configcruisecontrol.net

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?

Best Answer

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:

  <buildpublisher>
    <sourceDir>C:\ccnet_projects\Installer\bin\x86\Release</sourceDir>
    <dynamicValues>
      <replacementValue property="publishDir">
        <format>C:\builds\installers\{0}\x86</format>
        <parameters>
          <namedValue name="$CCNetLabel" value="Default" />
        </parameters>
      </replacementValue>
    </dynamicValues>
    <useLabelSubDirectory>false</useLabelSubDirectory>
  </buildpublisher>

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

  <buildpublisher>
    <sourceDir>C:\ccnet_projects\Installer\bin\x86\Release</sourceDir>
    <publishDir>C:\builds\installers\1.0.2.120\x86</publishDir>
    <useLabelSubDirectory>false</useLabelSubDirectory>
  </buildpublisher>      

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

Related Topic