• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mail task on Target failure

 
vinodh kumar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an ant project where there is a set of targets. After successful completion of all targets I call mail target at the end to send a mail with attached logs with message build successful.

Now, my challenge is if one of the target fails then build exits so it will not proceed to mail target which is the last one to perform on completion of all. How can I use mail target to send mail on any target failure?

Any hints?

-Vinodh Kumar
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Based on the command line options (http://ant.apache.org/manual/index.html) your two best bets are:

1) Try the -k option

2) Write a CustomExitCode class and invoke the mail target from within it.

Of course, you could always create a script that does:

ant xxx yyy
ant mail

That way the mail target would always run. You'd probably have to tweak the mail target since it would be mailing the result from the prior ant run.

Another thought: having a "finally" target that runs before exit whether the build passed or failed is a good idea. If you created a patch to do that you could submit it back to the community.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic