You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by p2008 <pr...@gmail.com> on 2008/07/23 00:35:19 UTC

How to run an ant target on success/failed build

I need to be able to trigger running a specific ant target when the build
succeeds, and another one when it fails.  This will be used to send out an
email indicating the status of the build.

I have done this in the past in nant (.NET) which has a built in property
called nant.onsuccess and one called nant.onfailure.  

Is there something similar in ant, or any does anybody know how to do this?

Thanks!
-- 
View this message in context: http://www.nabble.com/How-to-run-an-ant-target-on-success-failed-build-tp18600235p18600235.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: How to run an ant target on success/failed build

Posted by p2008 <pr...@gmail.com>.
For anyone else who is interested in this presentation, the problem addresses
in this thread starts on Slide 34, so jump ahead!

http://people.apache.org/~kevj/ossummit/extending-ant.html




Rebhan, Gilbert wrote:
> 
>  
> 
> -----Original Message-----
> From: p2008 [mailto:prempel@gmail.com] 
> Sent: Wednesday, July 23, 2008 12:35 AM
> To: user@ant.apache.org
> Subject: How to run an ant target on success/failed build
> 
> /*
> I need to be able to trigger running a specific ant target when the
> build
> succeeds, and another one when it fails.  This will be used to send out
> an
> email indicating the status of the build.
> 
> I have done this in the past in nant (.NET) which has a built in
> property
> called nant.onsuccess and one called nant.onfailure.  
> 
> Is there something similar in ant, or any does anybody know how to do
> this?
> */
> 
> There's a nice presentation from Kev Jackson, that has an example
> with exec-listener, src included =
> 
> http://people.apache.org/~kevj/ossummit/extending-ant.html
> 
> That listener is exactly what you're looking for.
> 
> Regards, Gilbert
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-run-an-ant-target-on-success-failed-build-tp18600235p18616082.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: How to run an ant target on success/failed build

Posted by p2008 <pr...@gmail.com>.
Thanks for this info!  It seems the exec listener is the most flexible
solution.  Not quite as simple as the hooks offered in nant, but it should
do the job. Thanks.



Rebhan, Gilbert wrote:
> 
>  
> 
> -----Original Message-----
> From: p2008 [mailto:prempel@gmail.com] 
> Sent: Wednesday, July 23, 2008 12:35 AM
> To: user@ant.apache.org
> Subject: How to run an ant target on success/failed build
> 
> /*
> I need to be able to trigger running a specific ant target when the
> build
> succeeds, and another one when it fails.  This will be used to send out
> an
> email indicating the status of the build.
> 
> I have done this in the past in nant (.NET) which has a built in
> property
> called nant.onsuccess and one called nant.onfailure.  
> 
> Is there something similar in ant, or any does anybody know how to do
> this?
> */
> 
> There's a nice presentation from Kev Jackson, that has an example
> with exec-listener, src included =
> 
> http://people.apache.org/~kevj/ossummit/extending-ant.html
> 
> That listener is exactly what you're looking for.
> 
> Regards, Gilbert
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-run-an-ant-target-on-success-failed-build-tp18600235p18615045.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: How to run an ant target on success/failed build

Posted by "Rebhan, Gilbert" <Gi...@huk-coburg.de>.
 

-----Original Message-----
From: p2008 [mailto:prempel@gmail.com] 
Sent: Wednesday, July 23, 2008 12:35 AM
To: user@ant.apache.org
Subject: How to run an ant target on success/failed build

/*
I need to be able to trigger running a specific ant target when the
build
succeeds, and another one when it fails.  This will be used to send out
an
email indicating the status of the build.

I have done this in the past in nant (.NET) which has a built in
property
called nant.onsuccess and one called nant.onfailure.  

Is there something similar in ant, or any does anybody know how to do
this?
*/

There's a nice presentation from Kev Jackson, that has an example
with exec-listener, src included =

http://people.apache.org/~kevj/ossummit/extending-ant.html

That listener is exactly what you're looking for.

Regards, Gilbert

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How to run an ant target on success/failed build

Posted by Olivier Gies <ol...@bull.net>.
One solution is to use ant-contrib's <trycatch> task:

1) Direct usage:
<trycatch>
	<try>
		<!-- Your code here -->

		<mail message="Success" ... >
	</try>
	<catch>
		<mail message="Failure" ... >
	</catch>
</trycatch>

2) If you need the failure message in the mail (in combination with 
ant-contrib's <if>):

<trycatch property="errormessage">
	<try>
		<!-- Your code here -->
	</try>
	<catch>
	</catch>
</trycatch>

<if>
	<not><isset property="errormessage"/></not>
	<then>
		<mail message="Success" ... >
	</then>
	<else>
		<mail message="Failure: ${errormessage}" ... >
	</else>
</if>


See http://ant-contrib.sourceforge.net/tasks/tasks/index.html for more 
details.

Regrads,


*Olivier Gies*

*Delivery Manager
Customs & Tax Software Engineering Center
Bull, Architect of an Open World ^TM
Phone: +86 (10) 65978001 - Ext 555 *

*www.bull.com <http://www.bull.com/>*

*This e-mail contains material that is confidential for the sole use of
the intended recipient. Any review, reliance or distribution by others
or forwarding without express permission is strictly prohibited. If you
are not the intended recipient, please contact the sender and delete all
copies.*



-------- Original Message  --------
Subject: How to run an ant target on success/failed build
From: p2008 <pr...@gmail.com>
To: user@ant.apache.org
Date: 23/07/2008 06:36

> I need to be able to trigger running a specific ant target when the build
> succeeds, and another one when it fails.  This will be used to send out an
> email indicating the status of the build.
> 
> I have done this in the past in nant (.NET) which has a built in property
> called nant.onsuccess and one called nant.onfailure.  
> 
> Is there something similar in ant, or any does anybody know how to do this?
> 
> Thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: AW: How to run an ant target on success/failed build

Posted by p2008 <pr...@gmail.com>.
Interesting, I didn't know you could do that.  However I want to add some
custom messages and maybe some extra logic - not just mailing the logs.  

I think Cruise Control is a good solution to manage the email notifications. 
I am going to be using it anyways for automated builds.


Knuplesch, Juergen wrote:
> 
> You can do this by configuring the maillogger in your startscript:
> 
> ant build_ant.xml -logger org.apache.tools.ant.listener.MailLogger 
> 
> Then you have to set the following properties
> MailLogger.mailhost=
> MailLogger.from=
> MailLogger.failure.subject=failed
> MailLogger.success.subject=successfull
> MailLogger.success.to=someone@somewhwere.xx
> MailLogger.failure.to=someoneelse@somewhwere.xx
> 
> Then you will send the output of Ant to the specifies addresses.
> 
> Another strategy (big solution) is using CruiseControl
> 
> 
> 
> 
> 
> 
> -- 
> Jürgen Knuplesch
> -----Ursprüngliche Nachricht-----
> Von: p2008 [mailto:prempel@gmail.com] 
> Gesendet: Mittwoch, 23. Juli 2008 00:35
> An: user@ant.apache.org
> Betreff: How to run an ant target on success/failed build
> 
> 
> I need to be able to trigger running a specific ant target when the build
> succeeds, and another one when it fails.  This will be used to send out an
> email indicating the status of the build.
> 
> I have done this in the past in nant (.NET) which has a built in property
> called nant.onsuccess and one called nant.onfailure.  
> 
> Is there something similar in ant, or any does anybody know how to do
> this?
> 
> Thanks!
> --
> View this message in context:
> http://www.nabble.com/How-to-run-an-ant-target-on-success-failed-build-tp18600235p18600235.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-run-an-ant-target-on-success-failed-build-tp18600235p18615588.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


AW: How to run an ant target on success/failed build

Posted by "Knuplesch, Juergen" <Ju...@icongmbh.de>.
You can do this by configuring the maillogger in your startscript:

ant build_ant.xml -logger org.apache.tools.ant.listener.MailLogger 

Then you have to set the following properties
MailLogger.mailhost=
MailLogger.from=
MailLogger.failure.subject=failed
MailLogger.success.subject=successfull
MailLogger.success.to=someone@somewhwere.xx
MailLogger.failure.to=someoneelse@somewhwere.xx

Then you will send the output of Ant to the specifies addresses.

Another strategy (big solution) is using CruiseControl






-- 
Jürgen Knuplesch
-----Ursprüngliche Nachricht-----
Von: p2008 [mailto:prempel@gmail.com] 
Gesendet: Mittwoch, 23. Juli 2008 00:35
An: user@ant.apache.org
Betreff: How to run an ant target on success/failed build


I need to be able to trigger running a specific ant target when the build succeeds, and another one when it fails.  This will be used to send out an email indicating the status of the build.

I have done this in the past in nant (.NET) which has a built in property called nant.onsuccess and one called nant.onfailure.  

Is there something similar in ant, or any does anybody know how to do this?

Thanks!
--
View this message in context: http://www.nabble.com/How-to-run-an-ant-target-on-success-failed-build-tp18600235p18600235.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org