views:

263

answers:

2

In the build log of my project, i can see these properties:

<integrationProperties>
  <CCNetProject>Gdet_T</CCNetProject>
  ...
  <LastModificationDate>4/6/2010 1:29:04 PM</LastModificationDate>
  <LastChangeNumber>10841</LastChangeNumber>
</integrationProperties>

I want to pass the property CCNetProject and LastChangeNumber to a batch file. it works well with CCNetProject, as it can be used in the batch as an environment variable %CCNetProject%.

But it doesn't work with other properties (those are not starting with the CCnet prefix) as LastChangeNumber or LastModificationDate.

I tried to pass it as argument, but it fails !

<exec>
  <executable>$(WorkingFolderBase)\MyBatch.bat</executable>
  <baseDirectory>$(WorkingFolderBase)\</baseDirectory>
  <buildArgs>$(LastModificationDate)</buildArgs>
</exec>

I tried to pass it as environment variable, but it fails:

<exec>
  <executable>$(WorkingFolderBase)\MyBatch.bat</executable>
  <baseDirectory>$(WorkingFolderBase)\</baseDirectory>
  <environment>
    <variable>
      <name>svn_label</name>
      <value>"${LastModificationDate}"</value>
    </variable>
  </environment>
</exec>

The results is always the same when I display the parameter or variable : empty string or the variable name $(svn_label)

I'm sure it is simple, but ... I can't find ! Any idea ?

+2  A: 

CCNET passes the following parameters to external programs:

CCNetArtifactDirectory 
CCNetBuildCondition 
CCNetBuildDate 
CCNetBuildTime 
CCNetFailureUsers 
CCNetIntegrationStatus 
CCNetLabel 
CCNetLastIntegrationStatus 
CCNetListenerFile 
CCNetModifyingUsers 
CCNetNumericLabel 
CCNetProject 
CCNetProjectUrl 
CCNetRequestSource 
CCNetUser 
CCNetWorkingDirectory 

As you can see LastIntegrationStatus e.g. is available through CCNetLastIntegrationStatus but LastModificationDate e.g. has no equivalent.

You can pass additional arguments via <buildArgs> or <environment> but inside CCNET configuration you have no access on the integration properties mentioned above. Most people starting with CCNET (including myself) try something like <buildArgs>$(CCNetProject)</buildArgs> and fail.

Have a look on my answer to a similar question.

Sorry I can't provide a better solution.

Update (regarding Thinker's suggestion):

Using $[$CCNetLabel] inside CCNET configuration does not seem to work.

Frankly spoken, I would have been rather surprised, if it had. The configuration is something static whereas CCNetLabel is something dynamic, that potentially changes with every integration build. Assuming you have access to these dynamic properties inside the configuration, the configuration might change with every build. Since changing the configuration means restarting the CCNET server automatically, you would cause a server restart with every build. Not actually a desirable behavior, is it?

The Chairman
Looking at the old question I mentioned I found this answer by Thinker: http://stackoverflow.com/questions/1563362/cruisecontrol-net-using-ccnetlabel-inside-ccnet-config-file/2299848#2299848. I will give this solution a try tomorrow.
The Chairman
Yeah, I will try also tomorrow the ccnet labeler to get the svn revision number
TridenT
Nope. Does not work for me.
The Chairman
I even can't get the svn revision in CC.NET ... even with a labeller block ... pretty hard for a small request : pass the svn revision to a batch file.Maybe I should open a new question with this title ?
TridenT
If it's just about accessing the label in a batch file there might be a workaround: Choose the appropriate labeler in Your CCNET configuration (e.g. Last Change Labeller [sic], http://confluence.public.thoughtworks.org/display/CCNET/Last+Change+Labeller) and access it via `%CCNetLabel%`. That won't give You access to SCM's modification date and labeler behavior depends on the SCM type but you possibly could get `LastChangeNumber` in the batch file.
The Chairman
A: 

ok, found the solution. Need to use a specific label called SvnRevisionLabeller to retrieve the svn revision. it is then available via the CCNetLabel environement variable.

http://code.google.com/p/svnrevisionlabeller/

<labeller type="svnRevisionLabeller"> 
  <url>http://mysvnrootproject/trunk&lt;/url&gt; 
</labeller>
TridenT
It is a little weird, but I will accept my reply :)Thank you guys for helping me, it was very usefull for investigation.
TridenT