• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mail task on Target failure

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic