title: Ant build to fail but always execute a target in Jenkins
body: <p>[Solved] - The correct ant contrib jar was not getting picked up from the default location on my system. Have to give path manually in the build xml like this:</p>
  
  <pre><code>    &lt;taskdef resource="net/sf/antcontrib/antlib.xml"&gt;
          &lt;classpath&gt;
              &lt;pathelement location="/usr/share/ant/lib/ant-contrib-1.0b3.jar"/&gt;
          &lt;/classpath&gt;
      &lt;/taskdef&gt;
  -------------------------------------------
  </code></pre>
  
  <p>Q: I have a python script that is run through ant/Jenkins like this:</p>
  
  <pre><code>&lt;project name="prjName"&gt; 
      &lt;target name="preRun" description="do something"&gt;
      .... 
      &lt;/target&gt;
      &lt;target name="Run" description="Run the python script"&gt;
          &lt;exec executable="python" failonerror="true"&gt;
             &lt;arg value="${basedir}/run.py" /&gt;
             &lt;arg value="something" /&gt;
          &lt;/exec&gt;
      &lt;/target&gt;
      &lt;target name="other1" description="do something"&gt;
       ....
      &lt;/target&gt;
  
      &lt;target name="other2" description="do something"&gt;
       ....
      &lt;/target&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>Now this python script runs an external tool (web-inject which produces some result files) and keeps on scanning for the word FAIL in the logs. As soon as it finds FAIL, it does <code>sys.exit("Error")</code></p>
  
  <p>Thus the build fails but I still want to execute the target - other1. Is it possible through try-catch? I am doing it like this but it isn't working</p>
  
  <pre><code>    &lt;macrodef name="test-case"&gt;     
           &lt;sequential&gt; 
               &lt;trycatch&gt;
                  &lt;try&gt;
                      &lt;exec executable="python" failonerror="true"&gt;
                          &lt;arg value="${basedir}/read.py" /&gt;
                      &lt;/exec&gt;
                  &lt;/try&gt;
                  &lt;catch&gt;
                      &lt;echo&gt;Investigate exceptions in the run!&lt;/echo&gt;
                  &lt;/catch&gt;
                  &lt;finally&gt;
                      &lt;antcall target="other1" /&gt;
                  &lt;/finally&gt;
              &lt;/trycatch&gt;
           &lt;/sequential&gt;   
          &lt;/macrodef&gt;    
  
  
  &lt;target name="other1" description="do something"&gt;
           ....
  &lt;/target&gt;
  </code></pre>