Search code examples
scriptingantwebspherewebsphere-mq-fte

How to obtain return codes for ant tasks in a ant script?


I am working with mqfte. Is it possible to capture the return code of all the ant tasks i have used in a ant script?


Solution

  • Within the FTE Ant job, each step will have a SuccessRC specification. In order to proceed past that step, the return code must be successful. If the job fails, then the failing return code will be reported in the log entry.

    For example, in the following job the pre-source call encrypts a file prior to transfer and a post-source call deletes the plaintext version of the file if the transfer is successful. By definition, if the transfer fails, the non-zero return code will be reported in the FTE log. Otherwise the calls succeeded and we know that the return codes were all zero.

    <request version="4.00" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FileTransfer.xsd">
     <managedTransfer>
      <originator>
          <hostName>${hostName}</hostName>
          <userID>${userID}</userID>
        </originator>
        <sourceAgent QMgr="${sourceQM}" agent="${sourceAgent}"/>
        <destinationAgent QMgr="${destQM}" agent="${destAgent}"/>
        <transferSet priority="5">
          <metaDataSet>
            <metaData key="Cost_Center">1234</metaData>
          </metaDataSet>
          <preSourceCall> 
            <command  type="executable" name="/usr/bin/gpg" successRC="0"> 
              <argument>-es</argument> 
              <argument>--batch</argument> 
              <argument>-r</argument> 
              <argument>${signame}</argument> 
              <argument>--output</argument> 
              <argument>${FILEPATH}.gpg</argument> 
              <argument>--passphrase-file</argument> 
              <argument>${pwdfile}</argument> 
              <argument>${FILEPATH}</argument> 
            </command> 
          </preSourceCall> 
          <postSourceCall> 
            <command  type="executable" name="/var/IBM/WMQFTE/user/ant/rm" successRC="0"> 
              <argument>${FILEPATH}</argument> 
            </command> 
          </postSourceCall> 
          <item checksumMethod="MD5" mode="binary">
            <source disposition="delete" recursive="false">
              <file>${FILEPATH}.gpg</file>
            </source>
            <destination exist="overwrite" type="directory">
              <file>${targetDir}</file>
            </destination>
          </item>
        </transferSet>
        <job>
          <name>gpge.xml</name>
        </job>
      </managedTransfer>
    </request>