在我的 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/