How can I set a job status programmatically?

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

How can I set a job status programmatically?

Peter Steele
I want to create a job step called "Set Status" that when added to a workflow will be set to always run and it will set the workflow's status to either "success" or "failure" depending on whether any of the steps in the workflow failed. How do I code this kind of logic in a job step?


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

RE: How can I set a job status programmatically?

Yanko, Curtis
You need two steps to do this. One to run if 'all steps passed' that sets the 'success' and the other set to run if 'any step failed' that sets failed.
 
==========
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 Peter Steele
Sent: Thursday, March 05, 2009 8:34 AM
To: [hidden email]
Subject: [Anthill-pro] How can I set a job status programmatically?

I want to create a job step called "Set Status" that when added to a workflow will be set to always run and it will set the workflow's status to either "success" or "failure" depending on whether any of the steps in the workflow failed. How do I code this kind of logic in a job step?

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: How can I set a job status programmatically?

Ryan Smith-3-3
Peter,

This can be done, you just have to specify a script on the step to
select the status. I modified one I had that only looked at the steps on
the current job. The first script looks at the steps on the current job
and assigns success/failure accordingly. The second script is the one
you want that looks at all steps on all jobs of the workflow.



import com.urbancode.anthill3.services.jobs.JobStatusEnum;
result = ProjectLookup.getCurrent().getStatusGroup().SUCCESS();
stepArray = JobTraceLookup.getCurrent().getStepTraceArray();
for (int s = 0; s < stepArray.length; s++) {
    if (!stepArray[s].isIgnoreMyFailures() &&
        stepArray[s].getStatus() == JobStatusEnum.FAILED) {
        result = ProjectLookup.getCurrent().getStatusGroup().FAILURE();
        break;
    }
}
return result;

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

import com.urbancode.anthill3.services.jobs.JobStatusEnum;
project = ProjectLookup.getCurrent();
success = project.getStatusGroup().SUCCESS();
failure = project.getStatusGroup().FAILURE();
result = success;
workflow = WorkflowLookup.getCurrentCase();
jobArray = workflow.getJobTraceArray();
for (int j=0; j<jobArray.length; j++) {
    stepArray = jobArray[j].getStepTraceArray();
    for (int s = 0; s < stepArray.length; s++) {
        if (!stepArray[s].isIgnoreMyFailures() &&
            JobStatusEnum.FAILED.equals(stepArray[s].getStatus())) {
            result = failure;
            break;
        }
    }
    if (failure.equals(result)) {
        break;
    }
}
return result;




Ryan Smith


Yanko, Curtis wrote:

> You need two steps to do this. One to run if 'all steps passed' that
> sets the 'success' and the other set to run if 'any step failed' that
> sets failed.
>  
> ==========
> 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 *Peter
> Steele
> *Sent:* Thursday, March 05, 2009 8:34 AM
> *To:* [hidden email]
> *Subject:* [Anthill-pro] How can I set a job status programmatically?
>
> I want to create a job step called "Set Status" that when added to a
> workflow will be set to always run and it will set the workflow's
> status to either "success" or "failure" depending on whether any of
> the steps in the workflow failed. How do I code this kind of logic in
> a job step?
>
> 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: How can I set a job status programmatically?

Peter Steele
In reply to this post by Yanko, Curtis
I should have mentioned that I already am using this approach. I just figured this could be done as a single job step with the beanshell magic.

----- Original Message -----
From: "Curtis Yanko" <[hidden email]>
To: "AnthillPro user and support list." <[hidden email]>
Sent: Thursday, March 5, 2009 5:40:38 AM GMT -08:00 US/Canada Pacific
Subject: RE: [Anthill-pro] How can I set a job status programmatically?

You need two steps to do this. One to run if 'all steps passed' that sets the 'success' and the other set to run if 'any step failed' that sets failed.
 
==========
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 Peter Steele
Sent: Thursday, March 05, 2009 8:34 AM
To: [hidden email]
Subject: [Anthill-pro] How can I set a job status programmatically?

I want to create a job step called "Set Status" that when added to a workflow will be set to always run and it will set the workflow's status to either "success" or "failure" depending on whether any of the steps in the workflow failed. How do I code this kind of logic in a job step?

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: How can I set a job status programmatically?

Peter Steele
In reply to this post by Ryan Smith-3-3
Thanks Ryan, I'll give this a try.

----- Original Message -----
From: "Ryan Smith" <[hidden email]>
To: "AnthillPro user and support list." <[hidden email]>
Sent: Thursday, March 5, 2009 6:16:08 AM GMT -08:00 US/Canada Pacific
Subject: Re: [Anthill-pro] How can I set a job status programmatically?

Peter,

This can be done, you just have to specify a script on the step to
select the status. I modified one I had that only looked at the steps on
the current job. The first script looks at the steps on the current job
and assigns success/failure accordingly. The second script is the one
you want that looks at all steps on all jobs of the workflow.



import com.urbancode.anthill3.services.jobs.JobStatusEnum;
result = ProjectLookup.getCurrent().getStatusGroup().SUCCESS();
stepArray = JobTraceLookup.getCurrent().getStepTraceArray();
for (int s = 0; s < stepArray.length; s++) {
    if (!stepArray[s].isIgnoreMyFailures() &&
        stepArray[s].getStatus() == JobStatusEnum.FAILED) {
        result = ProjectLookup.getCurrent().getStatusGroup().FAILURE();
        break;
    }
}
return result;

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

import com.urbancode.anthill3.services.jobs.JobStatusEnum;
project = ProjectLookup.getCurrent();
success = project.getStatusGroup().SUCCESS();
failure = project.getStatusGroup().FAILURE();
result = success;
workflow = WorkflowLookup.getCurrentCase();
jobArray = workflow.getJobTraceArray();
for (int j=0; j<jobArray.length; j++) {
    stepArray = jobArray[j].getStepTraceArray();
    for (int s = 0; s < stepArray.length; s++) {
        if (!stepArray[s].isIgnoreMyFailures() &&
            JobStatusEnum.FAILED.equals(stepArray[s].getStatus())) {
            result = failure;
            break;
        }
    }
    if (failure.equals(result)) {
        break;
    }
}
return result;




Ryan Smith


Yanko, Curtis wrote:

> You need two steps to do this. One to run if 'all steps passed' that
> sets the 'success' and the other set to run if 'any step failed' that
> sets failed.
>  
> ==========
> 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 *Peter
> Steele
> *Sent:* Thursday, March 05, 2009 8:34 AM
> *To:* [hidden email]
> *Subject:* [Anthill-pro] How can I set a job status programmatically?
>
> I want to create a job step called "Set Status" that when added to a
> workflow will be set to always run and it will set the workflow's
> status to either "success" or "failure" depending on whether any of
> the steps in the workflow failed. How do I code this kind of logic in
> a job step?
>
> 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

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

RE: How can I set a job status programmatically?

Yanko, Curtis
In reply to this post by Peter Steele
I feel that the normal way is more maintainable and flexible since I can still choose if a step can fail and not fail the build. Those sorts of things would start to make the script more and more complex where as it is trivial as it is in the advanced settings.
 
==========
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 Peter Steele
Sent: Thursday, March 05, 2009 10:14 AM
To: AnthillPro user and support list.
Subject: Re: [Anthill-pro] How can I set a job status programmatically?

I should have mentioned that I already am using this approach. I just figured this could be done as a single job step with the beanshell magic.

----- Original Message -----
From: "Curtis Yanko" <[hidden email]>
To: "AnthillPro user and support list." <[hidden email]>
Sent: Thursday, March 5, 2009 5:40:38 AM GMT -08:00 US/Canada Pacific
Subject: RE: [Anthill-pro] How can I set a job status programmatically?

You need two steps to do this. One to run if 'all steps passed' that sets the 'success' and the other set to run if 'any step failed' that sets failed.
 
==========
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 Peter Steele
Sent: Thursday, March 05, 2009 8:34 AM
To: [hidden email]
Subject: [Anthill-pro] How can I set a job status programmatically?

I want to create a job step called "Set Status" that when added to a workflow will be set to always run and it will set the workflow's status to either "success" or "failure" depending on whether any of the steps in the workflow failed. How do I code this kind of logic in a job step?

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
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: How can I set a job status programmatically?

Peter Steele
I suppose that's so, but in our case, we flag a build failed if any step fails, so for us this won't be a problem.

----- Original Message -----
From: "Curtis Yanko" <[hidden email]>
To: "AnthillPro user and support list." <[hidden email]>
Sent: Thursday, March 5, 2009 8:06:54 AM GMT -08:00 US/Canada Pacific
Subject: RE: [Anthill-pro] How can I set a job status programmatically?

I feel that the normal way is more maintainable and flexible since I can still choose if a step can fail and not fail the build. Those sorts of things would start to make the script more and more complex where as it is trivial as it is in the advanced settings.
 
==========
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 Peter Steele
Sent: Thursday, March 05, 2009 10:14 AM
To: AnthillPro user and support list.
Subject: Re: [Anthill-pro] How can I set a job status programmatically?

I should have mentioned that I already am using this approach. I just figured this could be done as a single job step with the beanshell magic.

----- Original Message -----
From: "Curtis Yanko" <[hidden email]>
To: "AnthillPro user and support list." <[hidden email]>
Sent: Thursday, March 5, 2009 5:40:38 AM GMT -08:00 US/Canada Pacific
Subject: RE: [Anthill-pro] How can I set a job status programmatically?

You need two steps to do this. One to run if 'all steps passed' that sets the 'success' and the other set to run if 'any step failed' that sets failed.
 
==========
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 Peter Steele
Sent: Thursday, March 05, 2009 8:34 AM
To: [hidden email]
Subject: [Anthill-pro] How can I set a job status programmatically?

I want to create a job step called "Set Status" that when added to a workflow will be set to always run and it will set the workflow's status to either "success" or "failure" depending on whether any of the steps in the workflow failed. How do I code this kind of logic in a job step?

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
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
|

Problem setting bugzilla bugs to resolved

william.hadden
Message
Hi,
 
I have been trying to create a packaging workflow step that would set bugs submitted to the originating workflow build as resolved.
 
The bugzilla resolve bug step seems to only accepts an explicitly named bug, not a bug pattern from a SCM commit like the other bugzilla steps.
 
Does anyone have any idea what I'm missing ( apart from the obvious ).
 
Wil

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

Re: How can I set a job status programmatically?

rgebbie
In reply to this post by Ryan Smith-3-3
The example scripts make sense, but it is not clear how to set a status other than success or failure.  

The 2 lines:

success = project.getStatusGroup().SUCCESS();
failure = project.getStatusGroup().FAILURE();

seem to set up the return values for success and failure, but I can't figure out how to set up a similar value to return for another status which is set up in the Life Cycle Model called "Snapshot".  I tried this:

snap = project.getStatus("Snapshot");

but that failed with a syntax error.

Do I have to look it up in the Life Cycle Model to get a status value for that status?
Reply | Threaded
Open this post in threaded view
|

Re: How can I set a job status programmatically?

Jon Neel
Try using project.getStatusGroup().getStatus("Snapshot");

Thanks,
Jon Neel
Support Developer
Urbancode, Inc.
Direct Line: (216) 539-0141
http://support.urbancode.com
http://www.urbancode.com



On Fri, Oct 26, 2012 at 8:06 PM, rgebbie <[hidden email]> wrote:

> The example scripts make sense, but it is not clear how to set a status
> other
> than success or failure.
>
> The 2 lines:
>
> success = project.getStatusGroup().SUCCESS();
> failure = project.getStatusGroup().FAILURE();
>
> seem to set up the return values for success and failure, but I can't
> figure
> out how to set up a similar value to return for another status which is set
> up in the Life Cycle Model called "Snapshot".  I tried this:
>
> snap = project.getStatus("Snapshot");
>
> but that failed with a syntax error.
>
> Do I have to look it up in the Life Cycle Model to get a status value for
> that status?
>
>
>
> --
> View this message in context:
> http://anthill-pro.1594311.n2.nabble.com/How-can-I-set-a-job-status-programmatically-tp2429409p7572851.html
> Sent from the Anthill-Pro mailing list archive at Nabble.com.
> _______________________________________________
> 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