How to pass an integration property to a batch file with CruiseControlNet?

半腔热情 提交于 2019-12-21 05:11:17

问题


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 ?


回答1:


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?




回答2:


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</url> 
</labeller>


来源:https://stackoverflow.com/questions/2592059/how-to-pass-an-integration-property-to-a-batch-file-with-cruisecontrolnet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!