You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by vino_hymi <vi...@gmail.com> on 2011/08/05 11:02:27 UTC

Mail task on Target failure

Hi,

I have ant project where there is 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

--
View this message in context: http://ant.1045680.n5.nabble.com/Mail-task-on-Target-failure-tp4669046p4669046.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: Mail task on Target failure

Posted by Martin Gainty <mg...@hotmail.com>.
i would launch n number of ant targets from bash e.g
#!/bin/bash

tname=ant_target_$1 > log
echo "ANT: Running $tname task..."
ant $tname
antReturnCode=$?
echo "ANT: Return code is: \""$antReturnCode"\""
if [ $antReturnCode -ne 0 ];then
    echo "BUILD ERROR: I am failing hard..."
else
    echo "SUCCESS"
fi

tname=ant_target_$2 >log
echo "ANT: Running $tname task..."
ant $tname
antReturnCode=$?
echo "ANT: Return code is: \""$antReturnCode"\""
 
if [ $antReturnCode -ne 0 ];then
    echo "BUILD ERROR: I am failing hard..."
else
    echo "SUCCESS"
fi

echo "send along the LOG file to the mail task"
ant mail log

Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.


> Date: Fri, 5 Aug 2011 15:06:57 -0400
> Subject: Re: Mail task on Target failure
> From: lgdean@cyrusinnovation.com
> To: user@ant.apache.org
> 
> I know TeamCity does keep the logs, or can be configured to do so.  It does
> for us.
> 
> Laura
> 
> On Fri, Aug 5, 2011 at 1:16 PM, glenn opdycke-hansen <gl...@gmail.com>wrote:
> 
> > +1 CI Servers.
> > It can be used to call an Ant script and email if there is success or
> > failure.  We notice that for some CI servers the log was not kept,
> > which is important for error situations.  But they are easy to set up,
> > so it worth investigating.
> >
> > --glenn
> >
> >
> >
> > On Fri, Aug 5, 2011 at 09:32, Laura Dean <lg...@cyrusinnovation.com>
> > wrote:
> > > To take a different approach: have you considered using a continuous
> > > integration server?  This is exactly the sort of thing they're good at,
> > and
> > > then your ant setup could just worry about building.
> > >
> > > I've used TeamCity and have heard good things about Jenkins (
> > > http://jenkins-ci.org/), but probably any of them could handle sending
> > > email, since that's one of the main features people want in such a
> > system.
> > >
> > > Laura
> > >
> > > On Fri, Aug 5, 2011 at 5:02 AM, vino_hymi <vi...@gmail.com> wrote:
> > >
> > >> Hi,
> > >>
> > >> I have ant project where there is 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
> > >>
> > >> --
> > >> View this message in context:
> > >>
> > http://ant.1045680.n5.nabble.com/Mail-task-on-Target-failure-tp4669046p4669046.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
> >
> >
 		 	   		  

Re: Mail task on Target failure

Posted by Laura Dean <lg...@cyrusinnovation.com>.
I know TeamCity does keep the logs, or can be configured to do so.  It does
for us.

Laura

On Fri, Aug 5, 2011 at 1:16 PM, glenn opdycke-hansen <gl...@gmail.com>wrote:

> +1 CI Servers.
> It can be used to call an Ant script and email if there is success or
> failure.  We notice that for some CI servers the log was not kept,
> which is important for error situations.  But they are easy to set up,
> so it worth investigating.
>
> --glenn
>
>
>
> On Fri, Aug 5, 2011 at 09:32, Laura Dean <lg...@cyrusinnovation.com>
> wrote:
> > To take a different approach: have you considered using a continuous
> > integration server?  This is exactly the sort of thing they're good at,
> and
> > then your ant setup could just worry about building.
> >
> > I've used TeamCity and have heard good things about Jenkins (
> > http://jenkins-ci.org/), but probably any of them could handle sending
> > email, since that's one of the main features people want in such a
> system.
> >
> > Laura
> >
> > On Fri, Aug 5, 2011 at 5:02 AM, vino_hymi <vi...@gmail.com> wrote:
> >
> >> Hi,
> >>
> >> I have ant project where there is 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
> >>
> >> --
> >> View this message in context:
> >>
> http://ant.1045680.n5.nabble.com/Mail-task-on-Target-failure-tp4669046p4669046.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
>
>

Re: Mail task on Target failure

Posted by glenn opdycke-hansen <gl...@gmail.com>.
+1 CI Servers.
It can be used to call an Ant script and email if there is success or
failure.  We notice that for some CI servers the log was not kept,
which is important for error situations.  But they are easy to set up,
so it worth investigating.

--glenn



On Fri, Aug 5, 2011 at 09:32, Laura Dean <lg...@cyrusinnovation.com> wrote:
> To take a different approach: have you considered using a continuous
> integration server?  This is exactly the sort of thing they're good at, and
> then your ant setup could just worry about building.
>
> I've used TeamCity and have heard good things about Jenkins (
> http://jenkins-ci.org/), but probably any of them could handle sending
> email, since that's one of the main features people want in such a system.
>
> Laura
>
> On Fri, Aug 5, 2011 at 5:02 AM, vino_hymi <vi...@gmail.com> wrote:
>
>> Hi,
>>
>> I have ant project where there is 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
>>
>> --
>> View this message in context:
>> http://ant.1045680.n5.nabble.com/Mail-task-on-Target-failure-tp4669046p4669046.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


Re: Mail task on Target failure

Posted by Laura Dean <lg...@cyrusinnovation.com>.
To take a different approach: have you considered using a continuous
integration server?  This is exactly the sort of thing they're good at, and
then your ant setup could just worry about building.

I've used TeamCity and have heard good things about Jenkins (
http://jenkins-ci.org/), but probably any of them could handle sending
email, since that's one of the main features people want in such a system.

Laura

On Fri, Aug 5, 2011 at 5:02 AM, vino_hymi <vi...@gmail.com> wrote:

> Hi,
>
> I have ant project where there is 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
>
> --
> View this message in context:
> http://ant.1045680.n5.nabble.com/Mail-task-on-Target-failure-tp4669046p4669046.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: Mail task on Target failure

Posted by Stefan Bodewig <bo...@apache.org>.
On 2011-08-05, vino_hymi wrote:

> I have ant project where there is 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?

Use the MailLogger instead of a custom target?

Stefan

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


RE: Mail task on Target failure

Posted by Adam Bruss <ab...@awrcorp.com>.
You could let the build go if an exec fails and store the result in an xml file. Then at the end check all the results and if one is non-zero fail after sending mail. 

To sum up, store the results of your tasks and check them all at the end. Send mail and then use the <fail> task if you need to fail the build.

Adam Bruss
Senior Development Engineer
AWR Corporation
11520 N. Port Washington Rd., Suite 201
Mequon, WI  53092  USA
P: 1.262.240.0291 x104
F: 1.262.240.0294
E: abruss@awrcorp.com
W: http://www.awrcorp.com

-----Original Message-----
From: vino_hymi [mailto:vinohymi@gmail.com] 
Sent: Friday, August 05, 2011 4:02 AM
To: user@ant.apache.org
Subject: Mail task on Target failure

Hi,

I have ant project where there is 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

--
View this message in context: http://ant.1045680.n5.nabble.com/Mail-task-on-Target-failure-tp4669046p4669046.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


Re: Mail task on Target failure

Posted by Parag Doke <pa...@gmail.com>.
There is the try/catch task in antcontrib
(http://ant-contrib.sourceforge.net/tasks/tasks/index.html) that
allows you to catch exceptions in tasks. I haven't tried this anytime
... but maybe you could try calling a target within such a block.

Thanks,
Parag Doke
Save paper, save trees. Do not print emails/documents unless
absolutely necessary.



On Fri, Aug 5, 2011 at 2:32 PM, vino_hymi <vi...@gmail.com> wrote:
> Hi,
>
> I have ant project where there is 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
>
> --
> View this message in context: http://ant.1045680.n5.nabble.com/Mail-task-on-Target-failure-tp4669046p4669046.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


Re: Mail task on Target failure

Posted by Vimil Saju <vi...@yahoo.com>.
Use the trycatch task from ant-contrib


________________________________
From: vino_hymi <vi...@gmail.com>
To: user@ant.apache.org
Sent: Friday, August 5, 2011 2:02 AM
Subject: Mail task on Target failure

Hi,

I have ant project where there is 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

--
View this message in context: http://ant.1045680.n5.nabble.com/Mail-task-on-Target-failure-tp4669046p4669046.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