【问题标题】:Ant Deploy Windows build manifests SVNAnt Deploy Windows 构建清单 SVN
【发布时间】:2012-01-19 09:50:11
【问题描述】:

各位,我正在使用 Eclipse、Subclipse 和 ANT。我想生成一个构建清单,其中包含来自 repo 的已更改、添加、更新、删除的文件(以及我当前系统上的各个版本号)。

    <propertyfile file="${dist.dir}\deploymentManifest.txt"
        comment="This file is automatically generated - DO NOT EDIT">        
        <entry key="buildtime" value="${builtat}"/>
        <entry key="build" value="${svnversion}"/>
        <entry key="version" value="${version}"/>
        <entry key="systemLocation" value="${directory/filename.ext}"/>
    </propertyfile>

如何从 Eclipse 中的文件中剥离这些信息?或者我如何使用 ANY 来检索此信息?

谢谢, 弗兰克

【问题讨论】:

    标签: eclipse deployment ant build manifest


    【解决方案1】:

    嗯,${buildtat} 可以取自 Ant 中的 &lt;tstamp&gt; 任务。其他的可以通过svn log --xml 解析,然后使用&lt;xmlproperties&gt; 任务生成的XML。就在我的脑海中(即没有错误检查):

    <!-- Gets the Time Stamp -->
    <tstamp>
      <format property="buildtat" pattern="MM/dd/yyyy HH:MM"/>
    </tstamp>
    
    <!-- Generates the revision information you need-->
    <exec
       executable="svn"
       output="${svn.log.file}">
       <arg line="log --xml -rHEAD/>
    </exec>
    
    <!-- Reads that information into a Property -->
    
    <xmlproperty file="${svn.log.file}"/>
    
    <echo message="Subversion Rev: ${log.logentry{revision}}"/>
    

    但是,我建议您查看像 Jenkins 这样的持续构建系统。每当您在 Subversion 存储库中进行更改时,Jenkins 都会获取更改并自动进行新的构建。这不仅允许您验证您的更改不会破坏您的构建,而且 Jenkins 还可以执行其他操作,例如运行 JUnit 测试。然后,Jenkins 将您的构建和测试结果以及整个构建日志存储在一个易于访问的 HTML 页面中。

    Jenkins 适合您的地方在于,Jenkins 会在构建过程中自动公开诸如 Subversion Revision 之类的内容。您可以获取 Subversion 版本、Jenkins 内部版本号、Jenkins 项目的名称以及许多其他内容作为环境变量。然后,您可以这样做:

    <property env="env."/>
    
    <propertyfile file="${dist.dir}\deploymentManifest.txt"
        comment="This file is automatically generated - DO NOT EDIT">        
        <entry key="buildtime" value="${env.BUILD_ID}"/>
        <entry key="build" value="${env.SVN_REVISION}"/>
        <entry key="version" value="${BUILD_NUMBER}"/>
        <entry key="systemLocation" value="${directory/filename.ext}"/>
    </propertyfile>
    

    看看詹金斯。它相当容易理解和使用。

    下载大约需要 5 分钟,在 Linux 系统上启动和运行可能需要 10 分钟。 Windows 更复杂,可能需要 15 到 20 分钟才能启动和运行。你现在可以在你的桌面系统上运行它,然后玩弄它。

    您可能需要再花半个小时来弄清楚如何设置一个可以在有人提交时自动构建的项目。

    Jenkins 是基于 Web 的,但带有自己的基于 Web 的轻量级应用程序引擎。您只需要 Java 1.6 即可运行它。 (而且,如果您使用的是 Eclipse,那么您应该已经拥有它)。

    【讨论】:

      猜你喜欢
      • 2012-04-09
      • 1970-01-01
      • 1970-01-01
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-26
      • 2010-10-15
      相关资源
      最近更新 更多