Hello Community,
I need to create an automation that changes the epic status based on the stories/tasks inside the epic.
For instance: automatic transition of an Epic to 'In Progress' when the first Story enters 'In Progress.'
Anyone has the code to help me with this situation using ScriptRunner, please?
Thanks in advance!
Hi Alexandra,
I can confirm that the code samples provided above will not work with ScriptRunner for Jira Clouddue to the fact the code you have provided is for ScriptRunner for Jira Server and this will not work as Atlassian only provide a rest API in Jira Cloud and do not provide a Java API in the cloud-like they do in Jira Server.
You can see more detailed information on the differences between the cloud and server versions inside of our documentation page located here.
We would recommend reviewing the documentation for ScriptRunner for Jira Cloud which is located here along with the Jira Cloud Rest API Documentation in order to see how the REST API's work in Jira cloud.
I can confirm that it is possible to achieve your requirement using ScriptRunner for Jira Cloud and can confirm that to achieve this that you would need to create a Script Listener which is configured on the Issue Updated event.
The script Listener code would need to return all of the linked issues linked to the epic issue and to check if the first story issue was in the required status and if it was to transition the epic issue.
I can confirm that the example script located here shows how to get stories attached to an epic and you will be able to use this script as a reference guide to see how to get the stories in order to check if the first story is in the required status.
I can also confirm that we have an example script located here which shows how to transition an issue when all linked issues are in the closed status and that this script may be a useful reference guide to see how to transition an issue.
You will be able to take these scripts and use this as a reference guide to help create the script that you require which transitions the epic issue when the first story is in the required status.
I hope this helps.
Regards,
Kristian
Very useful resources, I did miss that part :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alexandra Sousa DECSKILL @Leo @Kristian Walker _Adaptavist_ @Leonard Chew
I need to move epic from In Development to In QC
When all the story is in Done Status can u tell me how to do it .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've tried this code in Server platform but not on Cloud, it may need some minor changes
I placed this script in post-function of story workflow in "in progress" transition
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueInputParametersImpl
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.issueManager
IssueService issueService = ComponentAccessor.getIssueService()
def actionId = 31 // change this to the step that you want the issues to be transitioned to
def transitionValidationResult
def transitionResult
def epicLink = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Epic Link")
def epic = issue.getCustomFieldValue(epicLink) as String
if(epic){
def issueE = issueManager.getIssueObject(epic);
if(issueE.getStatus().name != "In Progress" )
{
transitionValidationResult = issueService.validateTransition(currentUser, issueE.id, actionId,new IssueInputParametersImpl())
if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (transitionResult.isValid())
{ log.debug("Transitioned issue $issue through action $actionId") }
else
{ log.debug("Transition result is not valid") }
}else{
log.debug("The transitionValidation is not valid")
}
}
}
Note: you must replace the actionID which is transition ID, also make sure Epic has transition to target status from current status, and check for validation/condition in workflow
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check this post. I have not tried it out myself. I hope it works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Leonard,
Thanks for your reply!
I already tried that option but it did not worked.
Thanks anyway!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.