ant - 在不失败的情况下停止ant脚本

标签 ant build ant-contrib

在我的 Ant 脚本中,我要退出(停止执行构建),而不会在满足条件时失败。我尝试使用:

<if>
    <equals arg1="${variable1}" arg2="${variable2}" />
  <then>
    <fail status="0" message="No change, exit" />
  </then>
</if>

Ant 脚本会在一定条件下停止,但是构建失败。我想停止构建,但没有错误。我在 Jenkins (Jenkins)中使用“调用 Ant ”步骤。

谢谢。

最佳答案

我建议通过重新考虑您的方法来重构您的 Ant 脚本。如果用“满足特定条件时执行构建”而不是“如果满足其他条件则使构建失败”来解决问题,则实现起来会更容易:

<!-- add on top of your build file -->
<if>
    <equals arg1="${variable1}" arg2="${variable2}" />
  <then>
    <property name="runBuild" value="true"/>
  </then>
  <else>
    <property name="runBuild" value="false"/>
  </else>
</if>


<!-- add to the target that shall be executed conditionally -->
<target name="myTarget" if="${runBuild}">
...

<!-- exit message as separate target -->
<target name="exitTarget" unless="${runBuild}">
  <echo message="No Change, exit" />
</target>

关于ant - 在不失败的情况下停止ant脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14130315/

相关文章:

ubuntu - Maven Ant SCP 错误

python - 匹配 Ant 路径的正则表达式

java - 如何将包含属性文件的目录添加到 Ant build.xml?

build - MSBuild:并行构建和 .Net 项目

build - TFS 不可知的 MSBuild 脚本

ant - ANT:如何读取在foreach循环中设置的属性

java - 在 Eclipse 中使用 Ant 的类路径

build - Sublime Text 2 通过简单的批处理文件构建

Ant 贡献 : equals doesn't work in for loop

java - Macro Def 属性不会改变其值