Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 543
minty Avatar asked Oct 13 '09 22:10

minty


3 Answers

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.)

like image 199
Darryl Avatar answered Nov 12 '22 22:11

Darryl


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

like image 39
Thinker Avatar answered Nov 12 '22 22:11

Thinker


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.
like image 9
moreira Avatar answered Nov 12 '22 21:11

moreira