[转]Getting svn revision number from NAnt

本文介绍了一种使用NAnt脚本从Subversion (SVN) 获取当前工作副本修订版本的方法。通过执行svn info --xml命令并解析返回的XML文件来实现。此方法适用于自动化部署流程。

本文转自:http://www.cosminonea.net/2009/10/getting-svn-revision-from-nant.html

 

http://stackoverflow.com/ has got the svn revison number in the footer which is quite cool especially when you have a build script that deploys the application automatically.

This is how you can get the revision from svn: 
svn info --xml [repository url]

which returns 
<?xml version="1.0"?> 
<info> 
  <entry 
     kind="dir" 
     path="." 
     revision="6"> 
    <url>http://svnserver/svn/svnrevisiondemo/trunk</url> 
    <repository> 
      <root>http://myserver/svn/svnrevisiondemo</root> 
      <uuid>cb474c29-17db-0310-ba2e-db2fec5ab780</uuid> 
    </repository> 
    <commit 
       revision="6"> 
      <author>cosmin</author> 
      <date>2009-10-25T17:09:08.315246Z</date> 
    </commit> 
  </entry> 
</info>

The most important bit in this output is the revision attribute of the commit node. This is the NAnt task that peeks into the xml above and extracts the revision number: 
    <target name="find-svnrevision"> 
        <property name="svn.revision" value="0"/> 
        <exec program="svn" 
            commandline='info "${project::get-base-directory()}" --xml' 
            output="svninfo.xml" 
            failonerror="false"/> 
        <xmlpeek 
            file="svninfo.xml" 
            xpath="/info/entry/commit/@revision" 
            property="svn.revision" 
            failonerror="false"/> 
        <echo message="Building revision number: ${svn.revision}"/> 
    <delete file="svninfo.xml" failonerror="false" /> 
  </target>

 

 

 

转载于:https://www.cnblogs.com/freeliver54/archive/2013/01/23/2872362.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值