I'm trying to deploy several systems with one script containing two targets. When one systems fails to deploy, I want to stop the whole script and fail.
<target name="deploy_all">
<for list="${systems}" param="system" delimiter="," parallel="false" threadCount="1" trim="true">
<sequential>
<antcall target="deploy_one_system">
<param name="system" value="@{system}" />
</antcall>
</sequential>
</for>
</target>
<target name="deploy_one_system">
<trycatch property="error_system">
<try>
<!-- deployment -->
<!-- Deep in other targets, there's <fail> -->
</try>
<catch>
<echo>Error during deployment of ${system}:</echo>
<echo>${error_system}</echo>
<!-- print logs, errors, cleanup -->
<if>
<contains string="${stop_execution_on_fail}" substring="${system}" />
<then>
<echo message="I should fail here!" />
<fail message="Error occured during deploying ${system}."/>
</then>
</if>
</catch>
</trycatch>
</target>
The problem is that the condition is evaluated correctly and message "I should fail here!" gets printed, but the build doesn't fail and continues deploying next system.
Variable ${stop_execution_on_fail} is supplied to the script and contains list of systems which should fail the whole build (instead of deploying the rest of systems).
Sometimes, the build fails after deploying several systems running out of memory.
17:07:03 deploy.xml:900:
17:07:03 The following error occurred while executing this line:
17:07:03 deploy.xml:908: The following error occurred while executing this line:
17:07:03 deploy.xml:802: Error occured during deploying system1.
17:07:03 The following error occurred while executing this line:
17:07:03 deploy.xml:908: The following error occurred while executing this line:
17:07:03 deploy.xml:802: Error occured during deploying system2.
17:07:03 The following error occurred while executing this line:
17:07:03 deploy.xml:908: The following error occurred while executing this line:
17:07:03 deploy.xml:802: Error occured during deploying system3.
17:07:03 The following error occurred while executing this line:
17:07:03 deploy.xml:908: The following error occurred while executing this line:
17:07:03 deploy.xml:4: java.lang.OutOfMemoryError: PermGen space
17:07:03 The following error occurred while executing this line:
17:07:03 deploy.xml:908: The following error occurred while executing this line:
17:07:03 deploy.xml:4: java.lang.OutOfMemoryError: PermGen space
I'm running Jenkins 1.642.1, JDK 1.8.0_74 and Ant 1.9.2.
Any ideas?
EDIT (based on pczeus' comment): The following is printed (don't mind timestamps, I took it from another build):
10:12:56 [echo] Error during deployment of system1:
10:12:56 [echo] The following error occurred while executing this line:
10:12:56 [echo] deploy.xml:739: The following error occurred while executing this line:
10:12:56 [echo] deploy.xml:647: The following error occurred while executing this line:
10:12:56 [echo] deploy.xml:473: The following error occurred while executing this line:
10:12:56 [echo] dbmaintain.xml:229: Unable to perform db maintain task.
--- omitted ---
10:12:56 [echo] I should fail here!
As you can see, the condition is evaluated successfully, as the message I should fail here! is printed.
stop_execution_on_fail variable contains comma-separated list of systems where to fail:
system1,system2,system3
I traced the error down using Chad Nouis' suggestion and found out the following:
parallel
attribute in <for>
call in deploy_all
target was set to true. In that case, even with threadCount
set to 1, Ant does fail the target, but doesn't prevent the for cycle from running next loop (although I'm convinced it should).Thank you, Chad Nouis!