Question with sample script - EventSelector

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Question with sample script - EventSelector

Ryan Feiock

Hello,

I am trying to use this sample script:

 

https://bugs.urbancode.com/browse/AHPSCRIPTS-11

 

To create an EventSelector that will only send notifications of successes after a failure.  When I plugged this in, it is not sending out any notification at all.  When I added a couple of logs to the script I am finding that for these lines:

 

currentSuccess = event.getCase().getBuildLife();

lastFailure = BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(currentSuccess, currentSuccess.getProfile());

lastSuccess = BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(currentSuccess, currentSuccess.getProfile());

 

lastFailure and lastSuccess are coming back “null”.  I started looking into this, and I logged out “currentSuccess” which is set to “BuildLife – BuildLife”.  I am guessing that this is incorrect and is the source of the error with the script.  The method restorePriorMostRecentFailureForProfile takes 2 parameters, “BuildLife” and “BuildProfile”.  Am I correct in my assumption, and if so, what should I be using to get the build life to pass into these methods?

 

Thanks

 


_______________________________________________
Anthill-pro mailing list
[hidden email]
http://lists.urbancode.com/mailman/listinfo/anthill-pro
Reply | Threaded
Open this post in threaded view
|

RE: Question with sample script - EventSelector

Yanko, Curtis
We use this to notify on failure and first success:
 
import com.urbancode.anthill3.domain.workflow.*;
import com.urbancode.anthill3.domain.buildlife.*;
 
result = false;
 
// Mail if there's a failure
if (event instanceof WorkflowEvent &&
    event.getCase().isComplete() &&
    !event.getCase().getStatus().isSuccess()) {
  result = true;
}
// Or if it's a success and the previous build was a failure
else if (event instanceof WorkflowEvent &&
    event.getCase().isComplete() &&
    event.getCase().getStatus().isSuccess()) {
        currentSuccess = event.getCase().getBuildLife();
        lastFailure =
BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(currentSuccess,
currentSuccess.getProfile());
        lastSuccess =
BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(currentSuccess,
currentSuccess.getProfile());
        if (lastFailure != null) {
            if (lastSuccess == null ||
lastFailure.getStartDate().after(lastSuccess.getStartDate())) {
                // This is a build fix
                result = true;
            }
        }
}
 
return result;
 
==========
Curtis Yanko
Application & Developer Infrastructure Services
Source->Build->Deploy
W: 860.702.9059
M: 860.881.2050
 


From: [hidden email] [mailto:[hidden email]] On Behalf Of Ryan Feiock
Sent: Wednesday, January 14, 2009 4:51 PM
To: [hidden email]
Subject: [Anthill-pro] Question with sample script - EventSelector

Hello,

I am trying to use this sample script:

 

https://bugs.urbancode.com/browse/AHPSCRIPTS-11

 

To create an EventSelector that will only send notifications of successes after a failure.  When I plugged this in, it is not sending out any notification at all.  When I added a couple of logs to the script I am finding that for these lines:

 

currentSuccess = event.getCase().getBuildLife();

lastFailure = BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(currentSuccess, currentSuccess.getProfile());

lastSuccess = BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(currentSuccess, currentSuccess.getProfile());

 

lastFailure and lastSuccess are coming back “null”.  I started looking into this, and I logged out “currentSuccess” which is set to “BuildLife – BuildLife”.  I am guessing that this is incorrect and is the source of the error with the script.  The method restorePriorMostRecentFailureForProfile takes 2 parameters, “BuildLife” and “BuildProfile”.  Am I correct in my assumption, and if so, what should I be using to get the build life to pass into these methods?

 

Thanks

 

This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity
to which it is addressed. If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited. If you have received this e-mail in error, please notify the
sender by replying to this message and delete this e-mail immediately.

_______________________________________________
Anthill-pro mailing list
[hidden email]
http://lists.urbancode.com/mailman/listinfo/anthill-pro
Reply | Threaded
Open this post in threaded view
|

Re: Question with sample script - EventSelector

emerson cargnin
Couldn't this be built-in anthill?


2009/1/15 Yanko, Curtis <[hidden email]>:

> We use this to notify on failure and first success:
>
> import com.urbancode.anthill3.domain.workflow.*;
> import com.urbancode.anthill3.domain.buildlife.*;
>
> result = false;
>
> // Mail if there's a failure
> if (event instanceof WorkflowEvent &&
>     event.getCase().isComplete() &&
>     !event.getCase().getStatus().isSuccess()) {
>   result = true;
> }
> // Or if it's a success and the previous build was a failure
> else if (event instanceof WorkflowEvent &&
>     event.getCase().isComplete() &&
>     event.getCase().getStatus().isSuccess()) {
>         currentSuccess = event.getCase().getBuildLife();
>         lastFailure =
> BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(currentSuccess,
> currentSuccess.getProfile());
>         lastSuccess =
> BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(currentSuccess,
> currentSuccess.getProfile());
>         if (lastFailure != null) {
>             if (lastSuccess == null ||
> lastFailure.getStartDate().after(lastSuccess.getStartDate())) {
>                 // This is a build fix
>                 result = true;
>             }
>         }
> }
>
> return result;
>
> ==========
> Curtis Yanko
> Application & Developer Infrastructure Services
> Source->Build->Deploy
> W: 860.702.9059
> M: 860.881.2050
>
> ________________________________
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Ryan Feiock
> Sent: Wednesday, January 14, 2009 4:51 PM
> To: [hidden email]
> Subject: [Anthill-pro] Question with sample script - EventSelector
>
> Hello,
>
> I am trying to use this sample script:
>
>
>
> https://bugs.urbancode.com/browse/AHPSCRIPTS-11
>
>
>
> To create an EventSelector that will only send notifications of successes
> after a failure.  When I plugged this in, it is not sending out any
> notification at all.  When I added a couple of logs to the script I am
> finding that for these lines:
>
>
>
> currentSuccess = event.getCase().getBuildLife();
>
> lastFailure =
> BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(currentSuccess,
> currentSuccess.getProfile());
>
> lastSuccess =
> BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(currentSuccess,
> currentSuccess.getProfile());
>
>
>
> lastFailure and lastSuccess are coming back "null".  I started looking into
> this, and I logged out "currentSuccess" which is set to "BuildLife –
> BuildLife".  I am guessing that this is incorrect and is the source of the
> error with the script.  The method restorePriorMostRecentFailureForProfile
> takes 2 parameters, "BuildLife" and "BuildProfile".  Am I correct in my
> assumption, and if so, what should I be using to get the build life to pass
> into these methods?
>
>
>
> Thanks
>
>
>
> This e-mail, including attachments, may include confidential and/or
> proprietary information, and may be used only by the person or entity
> to which it is addressed. If the reader of this e-mail is not the intended
> recipient or his or her authorized agent, the reader is hereby notified
> that any dissemination, distribution or copying of this e-mail is
> prohibited. If you have received this e-mail in error, please notify the
> sender by replying to this message and delete this e-mail immediately.
>
> _______________________________________________
> Anthill-pro mailing list
> [hidden email]
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>
>
_______________________________________________
Anthill-pro mailing list
[hidden email]
http://lists.urbancode.com/mailman/listinfo/anthill-pro
Reply | Threaded
Open this post in threaded view
|

Re: Question with sample script - EventSelector

emerson cargnin
I use this one which works alright:

import com.urbancode.anthill3.domain.workflow.*;

import com.urbancode.anthill3.dashboard.*;

boolean result = false;

if (event instanceof WorkflowEvent && event.getCase().isComplete()) {
    Long wid = event.getCase().getWorkflow().getId();
    BuildLifeWorkflowCaseSummary[]  blwcs=DashboardFactory.getInstance().
    getBuildLifeWorkflowSummariesByWorkflow(wid,null, new Integer(2));
    if(blwcs.length == 2){
        if(!blwcs[0].getStatus().equals(blwcs[1].getStatus())){
            result=true;
        }
    }
}

return result;



2009/1/15 emerson cargnin <[hidden email]>:

> Couldn't this be built-in anthill?
>
>
> 2009/1/15 Yanko, Curtis <[hidden email]>:
>> We use this to notify on failure and first success:
>>
>> import com.urbancode.anthill3.domain.workflow.*;
>> import com.urbancode.anthill3.domain.buildlife.*;
>>
>> result = false;
>>
>> // Mail if there's a failure
>> if (event instanceof WorkflowEvent &&
>>     event.getCase().isComplete() &&
>>     !event.getCase().getStatus().isSuccess()) {
>>   result = true;
>> }
>> // Or if it's a success and the previous build was a failure
>> else if (event instanceof WorkflowEvent &&
>>     event.getCase().isComplete() &&
>>     event.getCase().getStatus().isSuccess()) {
>>         currentSuccess = event.getCase().getBuildLife();
>>         lastFailure =
>> BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(currentSuccess,
>> currentSuccess.getProfile());
>>         lastSuccess =
>> BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(currentSuccess,
>> currentSuccess.getProfile());
>>         if (lastFailure != null) {
>>             if (lastSuccess == null ||
>> lastFailure.getStartDate().after(lastSuccess.getStartDate())) {
>>                 // This is a build fix
>>                 result = true;
>>             }
>>         }
>> }
>>
>> return result;
>>
>> ==========
>> Curtis Yanko
>> Application & Developer Infrastructure Services
>> Source->Build->Deploy
>> W: 860.702.9059
>> M: 860.881.2050
>>
>> ________________________________
>> From: [hidden email]
>> [mailto:[hidden email]] On Behalf Of Ryan Feiock
>> Sent: Wednesday, January 14, 2009 4:51 PM
>> To: [hidden email]
>> Subject: [Anthill-pro] Question with sample script - EventSelector
>>
>> Hello,
>>
>> I am trying to use this sample script:
>>
>>
>>
>> https://bugs.urbancode.com/browse/AHPSCRIPTS-11
>>
>>
>>
>> To create an EventSelector that will only send notifications of successes
>> after a failure.  When I plugged this in, it is not sending out any
>> notification at all.  When I added a couple of logs to the script I am
>> finding that for these lines:
>>
>>
>>
>> currentSuccess = event.getCase().getBuildLife();
>>
>> lastFailure =
>> BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(currentSuccess,
>> currentSuccess.getProfile());
>>
>> lastSuccess =
>> BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(currentSuccess,
>> currentSuccess.getProfile());
>>
>>
>>
>> lastFailure and lastSuccess are coming back "null".  I started looking into
>> this, and I logged out "currentSuccess" which is set to "BuildLife –
>> BuildLife".  I am guessing that this is incorrect and is the source of the
>> error with the script.  The method restorePriorMostRecentFailureForProfile
>> takes 2 parameters, "BuildLife" and "BuildProfile".  Am I correct in my
>> assumption, and if so, what should I be using to get the build life to pass
>> into these methods?
>>
>>
>>
>> Thanks
>>
>>
>>
>> This e-mail, including attachments, may include confidential and/or
>> proprietary information, and may be used only by the person or entity
>> to which it is addressed. If the reader of this e-mail is not the intended
>> recipient or his or her authorized agent, the reader is hereby notified
>> that any dissemination, distribution or copying of this e-mail is
>> prohibited. If you have received this e-mail in error, please notify the
>> sender by replying to this message and delete this e-mail immediately.
>>
>> _______________________________________________
>> Anthill-pro mailing list
>> [hidden email]
>> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>>
>>
>
_______________________________________________
Anthill-pro mailing list
[hidden email]
http://lists.urbancode.com/mailman/listinfo/anthill-pro
Reply | Threaded
Open this post in threaded view
|

Question with sample script - EventSelector

Ryan Feiock
In reply to this post by Ryan Feiock
Alright, I figured it out.  Based on what Eric Minick mentioned in his
post, I was not setting any kind of status (success or failure) on my
builds.  I was only using the status logic for what environments I
deployed to.  Since there is another status for builds (Complete or
Failed), I never understood why you would want to set a success or
failure status as well.  Well now I do.  In order to get any of the
below scripts working, you need to set the success or failure status
accordingly based on the build results.  Once I did that, the scripts
ran fine.

Thanks to everyone for their help,
Ryan


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of
[hidden email]
Sent: Thursday, January 15, 2009 3:12 PM
To: [hidden email]
Subject: Anthill-pro Digest, Vol 60, Issue 23

Send Anthill-pro mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.urbancode.com/mailman/listinfo/anthill-pro
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Anthill-pro digest..."


Today's Topics:

   1. Re: Question with sample script - EventSelector (emerson cargnin)
   2. RE: Anthill-pro Digest, Vol 60, Issue 22 (Ryan Feiock)
   3. Re: RE: Anthill-pro Digest, Vol 60, Issue 22 (Eric Minick)


----------------------------------------------------------------------

Message: 1
Date: Thu, 15 Jan 2009 17:21:09 +0000
From: "emerson cargnin" <[hidden email]>
Subject: Re: [Anthill-pro] Question with sample script - EventSelector
To: "AnthillPro user and support list."
        <[hidden email]>
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset=WINDOWS-1252

I use this one which works alright:

import com.urbancode.anthill3.domain.workflow.*;

import com.urbancode.anthill3.dashboard.*;

boolean result = false;

if (event instanceof WorkflowEvent && event.getCase().isComplete()) {
    Long wid = event.getCase().getWorkflow().getId();
    BuildLifeWorkflowCaseSummary[]
blwcs=DashboardFactory.getInstance().
    getBuildLifeWorkflowSummariesByWorkflow(wid,null, new Integer(2));
    if(blwcs.length == 2){
        if(!blwcs[0].getStatus().equals(blwcs[1].getStatus())){
            result=true;
        }
    }
}

return result;



2009/1/15 emerson cargnin <[hidden email]>:

> Couldn't this be built-in anthill?
>
>
> 2009/1/15 Yanko, Curtis <[hidden email]>:
>> We use this to notify on failure and first success:
>>
>> import com.urbancode.anthill3.domain.workflow.*;
>> import com.urbancode.anthill3.domain.buildlife.*;
>>
>> result = false;
>>
>> // Mail if there's a failure
>> if (event instanceof WorkflowEvent &&
>>     event.getCase().isComplete() &&
>>     !event.getCase().getStatus().isSuccess()) {
>>   result = true;
>> }
>> // Or if it's a success and the previous build was a failure
>> else if (event instanceof WorkflowEvent &&
>>     event.getCase().isComplete() &&
>>     event.getCase().getStatus().isSuccess()) {
>>         currentSuccess = event.getCase().getBuildLife();
>>         lastFailure =
>>
BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(c
urrentSuccess,
>> currentSuccess.getProfile());
>>         lastSuccess =
>>
BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(c
urrentSuccess,

>> currentSuccess.getProfile());
>>         if (lastFailure != null) {
>>             if (lastSuccess == null ||
>> lastFailure.getStartDate().after(lastSuccess.getStartDate())) {
>>                 // This is a build fix
>>                 result = true;
>>             }
>>         }
>> }
>>
>> return result;
>>
>> ==========
>> Curtis Yanko
>> Application & Developer Infrastructure Services
>> Source->Build->Deploy
>> W: 860.702.9059
>> M: 860.881.2050
>>
>> ________________________________
>> From: [hidden email]
>> [mailto:[hidden email]] On Behalf Of Ryan
Feiock

>> Sent: Wednesday, January 14, 2009 4:51 PM
>> To: [hidden email]
>> Subject: [Anthill-pro] Question with sample script - EventSelector
>>
>> Hello,
>>
>> I am trying to use this sample script:
>>
>>
>>
>> https://bugs.urbancode.com/browse/AHPSCRIPTS-11
>>
>>
>>
>> To create an EventSelector that will only send notifications of
successes
>> after a failure.  When I plugged this in, it is not sending out any
>> notification at all.  When I added a couple of logs to the script I
am
>> finding that for these lines:
>>
>>
>>
>> currentSuccess = event.getCase().getBuildLife();
>>
>> lastFailure =
>>
BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(c
urrentSuccess,
>> currentSuccess.getProfile());
>>
>> lastSuccess =
>>
BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(c
urrentSuccess,
>> currentSuccess.getProfile());
>>
>>
>>
>> lastFailure and lastSuccess are coming back "null".  I started
looking into
>> this, and I logged out "currentSuccess" which is set to "BuildLife -
>> BuildLife".  I am guessing that this is incorrect and is the source
of the
>> error with the script.  The method
restorePriorMostRecentFailureForProfile
>> takes 2 parameters, "BuildLife" and "BuildProfile".  Am I correct in
my
>> assumption, and if so, what should I be using to get the build life
to pass

>> into these methods?
>>
>>
>>
>> Thanks
>>
>>
>>
>> This e-mail, including attachments, may include confidential and/or
>> proprietary information, and may be used only by the person or entity
>> to which it is addressed. If the reader of this e-mail is not the
intended
>> recipient or his or her authorized agent, the reader is hereby
notified
>> that any dissemination, distribution or copying of this e-mail is
>> prohibited. If you have received this e-mail in error, please notify
the
>> sender by replying to this message and delete this e-mail
immediately.
>>
>> _______________________________________________
>> Anthill-pro mailing list
>> [hidden email]
>> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>>
>>
>


------------------------------

Message: 2
Date: Thu, 15 Jan 2009 13:30:00 -0500
From: "Ryan Feiock" <[hidden email]>
Subject: [Anthill-pro] RE: Anthill-pro Digest, Vol 60, Issue 22
To: <[hidden email]>
Message-ID:
       
<[hidden email]>
Content-Type: text/plain; charset="us-ascii"

Curtis,
Thanks for the response with the script.  I tried plugging that in, and
I get the exact same result.  It works fine for the failures, but I get
nothing for the resulting success.  When I log out what the variable
currentSuccess is, it is returning the value "BuildLife - BuildLife".
And then like before both lastFailure and lastSuccess are coming back
null.

Now I am starting to think it is something I am doing wrong.  First off,
I am running 3.5.4_20812 (not sure if that matters).  Second, the way I
am logging these variables is by using this:

import org.apache.log4j.*;

log = org.apache.log4j.Logger.getLogger("Scripted_Artifact_Resolve");
currentSuccess = event.getCase().getBuildLife();
log.warn("currentSuccess: " + currentSuccess);


Not sure if that is correct or not, but I don't know of any other way of
troubleshooting these issues.  And third, the way I am setting this up,
is I am going into "Event Selectors" and creating a new Event Selector.
I am pasting the script in there, and I named it "First successful after
last failed".  I then go to my notification scheme, and I add a new
"Who-When".  Under here I select my two roles I want to get notified,
select my script from the Case Selector, and add my Jabber IM template
for the Medium-Template.  I have a feeling this part is setup ok, since
I do correctly get notifications for failures.  

Any other ideas?

Thanks,
Ryan


-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of
[hidden email]
Sent: Thursday, January 15, 2009 12:10 PM
To: [hidden email]
Subject: Anthill-pro Digest, Vol 60, Issue 22

Send Anthill-pro mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.urbancode.com/mailman/listinfo/anthill-pro
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Anthill-pro digest..."


Today's Topics:

   1. Re: Question with sample script - EventSelector (emerson cargnin)


----------------------------------------------------------------------

Message: 1
Date: Thu, 15 Jan 2009 15:08:20 +0000
From: "emerson cargnin" <[hidden email]>
Subject: Re: [Anthill-pro] Question with sample script - EventSelector
To: "AnthillPro user and support list."
        <[hidden email]>
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset=WINDOWS-1252

Couldn't this be built-in anthill?


2009/1/15 Yanko, Curtis <[hidden email]>:

> We use this to notify on failure and first success:
>
> import com.urbancode.anthill3.domain.workflow.*;
> import com.urbancode.anthill3.domain.buildlife.*;
>
> result = false;
>
> // Mail if there's a failure
> if (event instanceof WorkflowEvent &&
>     event.getCase().isComplete() &&
>     !event.getCase().getStatus().isSuccess()) {
>   result = true;
> }
> // Or if it's a success and the previous build was a failure
> else if (event instanceof WorkflowEvent &&
>     event.getCase().isComplete() &&
>     event.getCase().getStatus().isSuccess()) {
>         currentSuccess = event.getCase().getBuildLife();
>         lastFailure =
>
BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(c
urrentSuccess,
> currentSuccess.getProfile());
>         lastSuccess =
>
BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(c
urrentSuccess,

> currentSuccess.getProfile());
>         if (lastFailure != null) {
>             if (lastSuccess == null ||
> lastFailure.getStartDate().after(lastSuccess.getStartDate())) {
>                 // This is a build fix
>                 result = true;
>             }
>         }
> }
>
> return result;
>
> ==========
> Curtis Yanko
> Application & Developer Infrastructure Services
> Source->Build->Deploy
> W: 860.702.9059
> M: 860.881.2050
>
> ________________________________
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Ryan
Feiock

> Sent: Wednesday, January 14, 2009 4:51 PM
> To: [hidden email]
> Subject: [Anthill-pro] Question with sample script - EventSelector
>
> Hello,
>
> I am trying to use this sample script:
>
>
>
> https://bugs.urbancode.com/browse/AHPSCRIPTS-11
>
>
>
> To create an EventSelector that will only send notifications of
successes

> after a failure.  When I plugged this in, it is not sending out any
> notification at all.  When I added a couple of logs to the script I am
> finding that for these lines:
>
>
>
> currentSuccess = event.getCase().getBuildLife();
>
> lastFailure =
>
BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(c
urrentSuccess,
> currentSuccess.getProfile());
>
> lastSuccess =
>
BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(c
urrentSuccess,
> currentSuccess.getProfile());
>
>
>
> lastFailure and lastSuccess are coming back "null".  I started looking
into
> this, and I logged out "currentSuccess" which is set to "BuildLife -
> BuildLife".  I am guessing that this is incorrect and is the source of
the
> error with the script.  The method
restorePriorMostRecentFailureForProfile
> takes 2 parameters, "BuildLife" and "BuildProfile".  Am I correct in
my
> assumption, and if so, what should I be using to get the build life to
pass

> into these methods?
>
>
>
> Thanks
>
>
>
> This e-mail, including attachments, may include confidential and/or
> proprietary information, and may be used only by the person or entity
> to which it is addressed. If the reader of this e-mail is not the
intended
> recipient or his or her authorized agent, the reader is hereby
notified
> that any dissemination, distribution or copying of this e-mail is
> prohibited. If you have received this e-mail in error, please notify
the
> sender by replying to this message and delete this e-mail immediately.
>
> _______________________________________________
> Anthill-pro mailing list
> [hidden email]
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>
>


------------------------------

_______________________________________________
Anthill-pro mailing list
[hidden email]
http://lists.urbancode.com/mailman/listinfo/anthill-pro


End of Anthill-pro Digest, Vol 60, Issue 22
*******************************************


------------------------------

Message: 3
Date: Thu, 15 Jan 2009 13:11:20 -0700
From: "Eric Minick" <[hidden email]>
Subject: Re: [Anthill-pro] RE: Anthill-pro Digest, Vol 60, Issue 22
To: "AnthillPro user and support list."
        <[hidden email]>
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

Ryan,

It's been a while, but I used this script to send out only when the
status
changes. I'm using the same basic strategy, I think. I do need to sanity
check that you are actually applying the "success" status at the end of
a
successful build and not some special "Ryan's Success" status? The most
recent success lookups are looking for the built in status.

import com.urbancode.anthill3.domain.buildlife.*;
import com.urbancode.anthill3.domain.workflow.*;
import com.urbancode.anthill3.dashboard.*;

boolean result = false;

if (event instanceof WorkflowEvent && event.getCase().isComplete()) {
  buildLifeFact = BuildLifeFactory.getInstance();
  buildLife = event.getCase().getBuildLife();
  buildStatus = event.getCase().getStatus();

priorSuccess =
buildLifeFact.restorePriorMostRecentSuccessForProfile(buildLife,
buildLife.getProfile());
priorFailure =
buildLifeFact.restorePriorMostRecentFailureForProfile(buildLife,
buildLife.getProfile());

if (priorSuccess != null && priorFailure != null) {
     boolean previousWasSuccess =
priorSuccess.getActualWorkspaceDate().after(priorFailure.getActualWorksp
aceDate());

if (previousWasSuccess != buildStatus.isSuccess()) {
        result = true;
     }
  }
  else if (buildStatus.isSuccess() && priorFailure != null) {
     result = true;
  }
  else if (!buildStatus.isSuccess() && priorSuccess != null) {
     result = true;
  }
  else { result = false; }
}

return result;
  [ Show > <https://bugs.urbancode.com/browse/AHPSCRIPTS-19> ]
 Eric
Minick<https://bugs.urbancode.com/secure/ViewProfile.jspa?name=eric%40ur
bancode.com>-
16/Jun/08
12:51 PM I find this to be more accurate (it's not confused by running
workflows or aborted ones) import
com.urbancode.anthill3.domain.buildlife.*;
import com.urbancode.anthill3.domain.workflow.*; import
com.urbancode.anthill3.dashboard.*; boolean result = false; if (event
instanceof WorkflowEvent && event.getCase().isComplete()) {
buildLifeFact
= BuildLifeFactory.getInstance();   buildLife =
event.getCase().getBuildLife();   buildStatus =
event.getCase().getStatus();
priorSuccess =
buildLifeFact.restorePriorMostRecentSuccessForProfile(buildLife,
buildLife.getProfile());   priorFailure =
buildLifeFact.restorePriorMostRecentFailureForProfile(buildLife,
buildLife.getProfile());    if (priorSuccess != null && priorFailure !=
null) {      boolean previousWasSuccess =
priorSuccess.getActualWorkspaceDate().after(priorFailure.getActualWorksp
aceDate());
   if (previousWasSuccess != buildStatus.isSuccess()) {         result =
true;      }   }   else if (buildStatus.isSuccess() && priorFailure !=
null)
{      result = true;   }   else if (!buildStatus.isSuccess() &&
priorSuccess != null) {      result = true;   }   else { result = false;
} }
     return result;


On Thu, Jan 15, 2009 at 11:30 AM, Ryan Feiock
<[hidden email]>wrote:

> Curtis,
> Thanks for the response with the script.  I tried plugging that in,
and
> I get the exact same result.  It works fine for the failures, but I
get
> nothing for the resulting success.  When I log out what the variable
> currentSuccess is, it is returning the value "BuildLife - BuildLife".
> And then like before both lastFailure and lastSuccess are coming back
> null.
>
> Now I am starting to think it is something I am doing wrong.  First
off,
> I am running 3.5.4_20812 (not sure if that matters).  Second, the way
I

> am logging these variables is by using this:
>
> import org.apache.log4j.*;
>
> log = org.apache.log4j.Logger.getLogger("Scripted_Artifact_Resolve");
> currentSuccess = event.getCase().getBuildLife();
> log.warn("currentSuccess: " + currentSuccess);
>
>
> Not sure if that is correct or not, but I don't know of any other way
of
> troubleshooting these issues.  And third, the way I am setting this
up,
> is I am going into "Event Selectors" and creating a new Event
Selector.
> I am pasting the script in there, and I named it "First successful
after
> last failed".  I then go to my notification scheme, and I add a new
> "Who-When".  Under here I select my two roles I want to get notified,
> select my script from the Case Selector, and add my Jabber IM template
> for the Medium-Template.  I have a feeling this part is setup ok,
since

> I do correctly get notifications for failures.
>
> Any other ideas?
>
> Thanks,
> Ryan
>
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> [hidden email]
> Sent: Thursday, January 15, 2009 12:10 PM
> To: [hidden email]
> Subject: Anthill-pro Digest, Vol 60, Issue 22
>
> Send Anthill-pro mailing list submissions to
>        [hidden email]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.urbancode.com/mailman/listinfo/anthill-pro
> or, via email, send a message with subject or body 'help' to
>        [hidden email]
>
> You can reach the person managing the list at
>        [hidden email]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Anthill-pro digest..."
>
>
> Today's Topics:
>
>   1. Re: Question with sample script - EventSelector (emerson cargnin)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 15 Jan 2009 15:08:20 +0000
> From: "emerson cargnin" <[hidden email]>
> Subject: Re: [Anthill-pro] Question with sample script - EventSelector
> To: "AnthillPro user and support list."
>        <[hidden email]>
> Message-ID:
>        <[hidden email]>
> Content-Type: text/plain; charset=WINDOWS-1252
>
> Couldn't this be built-in anthill?
>
>
> 2009/1/15 Yanko, Curtis <[hidden email]>:
> > We use this to notify on failure and first success:
> >
> > import com.urbancode.anthill3.domain.workflow.*;
> > import com.urbancode.anthill3.domain.buildlife.*;
> >
> > result = false;
> >
> > // Mail if there's a failure
> > if (event instanceof WorkflowEvent &&
> >     event.getCase().isComplete() &&
> >     !event.getCase().getStatus().isSuccess()) {
> >   result = true;
> > }
> > // Or if it's a success and the previous build was a failure
> > else if (event instanceof WorkflowEvent &&
> >     event.getCase().isComplete() &&
> >     event.getCase().getStatus().isSuccess()) {
> >         currentSuccess = event.getCase().getBuildLife();
> >         lastFailure =
> >
>
BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(c
> urrentSuccess,
> > currentSuccess.getProfile());
> >         lastSuccess =
> >
>
BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(c

> urrentSuccess,
> > currentSuccess.getProfile());
> >         if (lastFailure != null) {
> >             if (lastSuccess == null ||
> > lastFailure.getStartDate().after(lastSuccess.getStartDate())) {
> >                 // This is a build fix
> >                 result = true;
> >             }
> >         }
> > }
> >
> > return result;
> >
> > ==========
> > Curtis Yanko
> > Application & Developer Infrastructure Services
> > Source->Build->Deploy
> > W: 860.702.9059
> > M: 860.881.2050
> >
> > ________________________________
> > From: [hidden email]
> > [mailto:[hidden email]] On Behalf Of Ryan
> Feiock
> > Sent: Wednesday, January 14, 2009 4:51 PM
> > To: [hidden email]
> > Subject: [Anthill-pro] Question with sample script - EventSelector
> >
> > Hello,
> >
> > I am trying to use this sample script:
> >
> >
> >
> > https://bugs.urbancode.com/browse/AHPSCRIPTS-11
> >
> >
> >
> > To create an EventSelector that will only send notifications of
> successes
> > after a failure.  When I plugged this in, it is not sending out any
> > notification at all.  When I added a couple of logs to the script I
am
> > finding that for these lines:
> >
> >
> >
> > currentSuccess = event.getCase().getBuildLife();
> >
> > lastFailure =
> >
>
BuildLifeFactory.getInstance().restorePriorMostRecentFailureForProfile(c
> urrentSuccess,
> > currentSuccess.getProfile());
> >
> > lastSuccess =
> >
>
BuildLifeFactory.getInstance().restorePriorMostRecentSuccessForProfile(c
> urrentSuccess,
> > currentSuccess.getProfile());
> >
> >
> >
> > lastFailure and lastSuccess are coming back "null".  I started
looking
> into
> > this, and I logged out "currentSuccess" which is set to "BuildLife -
> > BuildLife".  I am guessing that this is incorrect and is the source
of
> the
> > error with the script.  The method
> restorePriorMostRecentFailureForProfile
> > takes 2 parameters, "BuildLife" and "BuildProfile".  Am I correct in
> my
> > assumption, and if so, what should I be using to get the build life
to

> pass
> > into these methods?
> >
> >
> >
> > Thanks
> >
> >
> >
> > This e-mail, including attachments, may include confidential and/or
> > proprietary information, and may be used only by the person or
entity
> > to which it is addressed. If the reader of this e-mail is not the
> intended
> > recipient or his or her authorized agent, the reader is hereby
> notified
> > that any dissemination, distribution or copying of this e-mail is
> > prohibited. If you have received this e-mail in error, please notify
> the
> > sender by replying to this message and delete this e-mail
immediately.

> >
> > _______________________________________________
> > Anthill-pro mailing list
> > [hidden email]
> > http://lists.urbancode.com/mailman/listinfo/anthill-pro
> >
> >
>
>
> ------------------------------
>
> _______________________________________________
> Anthill-pro mailing list
> [hidden email]
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>
>
> End of Anthill-pro Digest, Vol 60, Issue 22
> *******************************************
> _______________________________________________
> Anthill-pro mailing list
> [hidden email]
> http://lists.urbancode.com/mailman/listinfo/anthill-pro
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.urbancode.com/pipermail/anthill-pro/attachments/20090115/a3
667b8a/attachment.htm

------------------------------

_______________________________________________
Anthill-pro mailing list
[hidden email]
http://lists.urbancode.com/mailman/listinfo/anthill-pro


End of Anthill-pro Digest, Vol 60, Issue 23
*******************************************
_______________________________________________
Anthill-pro mailing list
[hidden email]
http://lists.urbancode.com/mailman/listinfo/anthill-pro