2017-04-24 48 views
0

我有一个Ant目标像下面这样:ANT递归调用,目标自称

<target name="validate_master_resources" description="Ensure the target is valid for local test run"> 

     <exec executable="bash" outputproperty="swap"> 
      <arg value="-c"/> 
      <arg value="free -m | grep '^Swap:' | awk '{print $4}'"/> 
     </exec> 

     <if> 
      <islessthan arg1="${swap}" arg2="5000"/> 
      <then> 
       <echo>the value of the swap memory is: ${swap}</echo> 
       <sleep minutes="10"/> 
       <runtarget target="validate_master_resources"/> 
      </then> 
     </if> 
</target> 

正如你可以看到它是一种递归的目标,validate_master_resources调用本身如果遇到一些condtions。

我决定使用runtarget(而不是ant调用),以避免创建新的ANT进程。

测试时特设了几个分钟的工作,正常工作,但在第2“真实世界”运行时,会在20分钟后会卡...

我运行作业詹金斯并且说,工作只是停留20分钟

后,正如你可以看到下面,它已被多次调用,然后卡住了几个小时,我需要将其杀死......

validate_master_resources: 
    [echo] The number of current Java processes is: 33 summed to the 45 is 78 

validate_master_resources: 
    [echo] The number of current Java processes is: 33 summed to the 45 is 78 

validate_master_resources: 
    [echo] The number of current Java processes is: 33 summed to the 45 is 78 

validate_master_resources: 
    [echo] The number of current Java processes is: 33 summed to the 45 is 78 

validate_master_resources: 
    [echo] The number of current Java processes is: 33 summed to the 45 is 78 

validate_master_resources: 
    [echo] The number of current Java processes is: 33 summed to the 45 is 78 

现在,我的问题是的,这个问题(构建卡)是否与这个蚂蚁任务递归的东西有关?

有没有任何任务过程/标签可以帮助我管理这样的递归?

我是否在非法模式下使用任务,并且错误行为取决于我创建的特定循环?

感谢

+0

“if”和“runtarget”任务都是ANT扩展的一部分,称为ant-contrib。两者都不是标准的一部分ANT –

+0

是的,我知道了吗? – ivoruJavaBoy

回答

0

有在这里没有问题,愚蠢的问题,唯一的问题是我是不是未设置在环路中的变量和我用始终不变的值,这导致的问题在其他地区导致过程挂起的脚本...

已解决!在蚂蚁中使用变量时要小心,有时候这个范围可能是一个难以管理的问题!