[Anthill-pro] Event Selector - comparing last build status
Uldis Karlovs-Karlovskis
uldisk at ctco.lv
Fri Feb 1 10:22:16 CST 2008
Ok, there is my script which works fine for me but I have some specific
buildlife configurations:
import com.urbancode.anthill3.domain.workflow.*;
import com.urbancode.anthill3.dashboard.* ;
import com.urbancode.anthill3.AnthillRuntimeException;
boolean result = false;
org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger("script");
if (event instanceof WorkflowEvent && event.getCase().isComplete())
{
Long wid = event.getCase().getWorkflow().getId();
if(event.getCase().getStatus().equals(WorkflowStatusEnum.RUNNING) ||
event.getCase().getStatus().equals(WorkflowStatusEnum.QUEUED) ||
event.getCase().getStatus().equals(WorkflowStatusEnum.ABORTING) ||
event.getCase().getStatus().equals(WorkflowStatusEnum.RESTARTING) ||
event.getCase().getStatus().equals(WorkflowStatusEnum.SUSPENDED) ||
event.getCase().getStatus().equals(WorkflowStatusEnum.WAITING_ON_AGENTS) ||
!(event.getCase().getBuildLife().getLatestStampValue().length()>1)){
logger.warn("BuildLife Not needed. Skipping BL " +
event.getCase().getBuildLife().getId().toString());
return false;
}
BuildLifeWorkflowCaseSummary[] blwcs;
try {
blwcs =
DashboardFactory.getInstance().getBuildLifeWorkflowSummariesByWorkflow(wid,
null, new Integer(30));
} catch (Exception e) {
logger.warn("There is less than 30 executed builds for
target workflow. Will try to retrieve from 5.");
}
if(blwcs == null || blwcs.length == 0){
try {
blwcs =
DashboardFactory.getInstance().getBuildLifeWorkflowSummariesByWorkflow(wid,
null, new Integer(5));
} catch (Exception e) {
logger.warn(e.getMessage());
logger.warn("There is less than 5 executed builds for
target workflow. No compare will be done");
return true;
}
}
int last = -1;
int previous = -1;
for(int i = 0; i < blwcs.length; i++){
if(blwcs[i].getStatus().equals(WorkflowStatusEnum.RUNNING)
||
blwcs[i].getStatus().equals(WorkflowStatusEnum.QUEUED) ||
blwcs[i].getStatus().equals(WorkflowStatusEnum.ABORTING) ||
blwcs[i].getStatus().equals(WorkflowStatusEnum.RESTARTING) ||
blwcs[i].getStatus().equals(WorkflowStatusEnum.SUSPENDED) ||
blwcs[i].getStatus().equals(WorkflowStatusEnum.WAITING_ON_AGENTS) ||
!(blwcs[i].getLatestStamp().length()>1)){
logger.warn("skipping BL " +
blwcs[i].getBuildLifeId().toString());
continue;
} else
if(blwcs[i].getStatus().equals(WorkflowStatusEnum.ABORTED) ||
blwcs[i].getStatus().equals(WorkflowStatusEnum.COMPLETE) ||
blwcs[i].getStatus().equals(WorkflowStatusEnum.COMPLETE_WARN) ||
blwcs[i].getStatus().equals(WorkflowStatusEnum.ERROR) ||
blwcs[i].getStatus().equals(WorkflowStatusEnum.FAILED) ){
if(last == -1){
last = i;
} else {
previous = i;
break;
}
} else {
logger.fatal("This is some misunderstanding. The state
for " + i + " were " + blwcs[i].getStatus().toString());
logger.fatal("last " + String.valueOf(last));
logger.fatal("previous " + String.valueOf(previous));
throw new AnthillRuntimeException("Problems with event
script");
}
}
if(last >= 0 && previous >= 1){
logger.warn("Last build status : " +
blwcs[last].getStatus().toString() + ", Stamp: " +
blwcs[last].getBuildLifeId().toString());
logger.warn("Previous build status : " +
blwcs[previous].getStatus().toString() + ", Stamp: " +
blwcs[previous].getBuildLifeId().toString());
if(!blwcs[last].getStatus().equals(blwcs[previous].getStatus())){
logger.warn("Considered as different");
result=true;
} else {
logger.warn("Considered as equal");
}
} else {
logger.warn("Not enough usable buildlifes so notification
will not be sent");
}
}
return result;
Uldis Karlovs-Karlovskis, C. T. Co
<mailto:uldis.karlovs-karlovskis at ctco.lv> uldis.karlovs-karlovskis at ctco.lv
-----Original Message-----
From: anthill-pro-bounces at lists.urbancode.com
[mailto:anthill-pro-bounces at lists.urbancode.com] On Behalf Of Yanko, Curtis
Sent: piektdiena, 2008. gada 1. februārī 18:15
To: AnthillPro user and support list.
Subject: RE: [Anthill-pro] Event Selector - comparing last build status
Has there been headway on this? I have a team that wants Failures and first
Success. While I fundamentally disagree with this approach they are the
customer.
===
-Curt
W: 860.702.9059
M: 860.881.2050
_____
From: anthill-pro-bounces at lists.urbancode.com
[mailto:anthill-pro-bounces at lists.urbancode.com] On Behalf Of Wes Bramhall
Sent: Wednesday, January 30, 2008 5:33 PM
To: AnthillPro user and support list.
Subject: [Anthill-pro] Event Selector - comparing last build status
I am trying to make a custom Event Selector that will notify if the current
build is a success and the previous one is a failure. How would I access the
previous build life to determine if it was a failure? I don't see a way to
access previous build lives except by status.
Thanks,
-Wes
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.urbancode.com/pipermail/anthill-pro/attachments/20080201/50f573c4/attachment-0003.htm
More information about the Anthill-pro
mailing list