Grokbase Groups Ant user July 2008
FAQ
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

Search Discussions

  • Olivier Gies at Jul 23, 2008 at 1:50 am
    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 <prempel@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
  • Knuplesch, Juergen at Jul 23, 2008 at 6:50 am
    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
    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
  • P2008 at Jul 23, 2008 at 4:58 pm
    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
    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
  • Rebhan, Gilbert at Jul 23, 2008 at 9:13 am
    -----Original Message-----
    From: p2008
    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
  • P2008 at Jul 23, 2008 at 4:33 pm
    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
    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
  • P2008 at Jul 23, 2008 at 5:22 pm
    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
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesant
postedJul 22, '08 at 10:35p
activeJul 23, '08 at 5:22p
posts7
users4
websiteant.apache.org

People

Translate

site design / logo © 2022 Grokbase