Basically I want to check if the file contains "SUCCESS" string. If string not found then ant has to exit with error message. Please help me on this. I tried many links but did'nt get this answer
You can do this with the Ant fail
task, assuming the file to check is called log.txt
:
<fail message="SUCCESS Found...failing">
<condition>
<resourcecontains resource="log.txt" substring="SUCCESS"/>
</condition>
</fail>
Here's an alternative approach, that you could adapt if you have more than one file to check.
<fileset id="success.file" dir="." includes="log.txt">
<contains text="SUCCESS"/>
</fileset>
<fail message="SUCCESS Found...failing">
<condition>
<resourcecount when="greater" count="0" refid="success.file" />
</condition>
</fail>
If none of the files in the fileset contain the string 'SUCCESS' then the fileset will be empty, so the build will not fail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With