Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set Resolution to an issue using Groovy

Vivian Escalante
Contributor
February 9, 2018

This is my scenario: 

I am closing an issue with groovy and I need to set the resolution to the issue. I don't want to use a post function because the issues being closed are the result of a JQL. 

3 answers

1 vote
Vivian Escalante
Contributor
February 9, 2018

def query = ..... //query that returns issues
def user = userManager.getUserByName(//some user)
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
def issues = results.issues.collect {issueManager.getIssueObject(it.id)}
def issueResolutionConstant = constantsManager.resolutions.findByName("Done")
IssueInputParameters param = issueService.newIssueInputParameters();

issues.each{ issue ->

//I then have code that checks if the transition is valid which works and changes the status to "Complete"

param.setResolutionId(issueResolutionConstant.id) //THIS IS WHAT I NEED HELP WITH

0 votes
Brittany Wispell
Community Champion
February 13, 2018

@Vivian Escalante you'll want to use something like this 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.ResolutionManager

def resolutionManager = ComponentAccessor.getComponent(ResolutionManager)

if (! issue.getResolutionObject() ) {
    issue.setResolution(resolutionManager.getResolutionByName("Done"))
}  

Where are you trying to execute this script?  

0 votes
Brittany Wispell
Community Champion
February 9, 2018

Hey @Vivian Escalante what is your existing code?  

Vivian Escalante
Contributor
February 12, 2018

@Brittany Wispell, any update here? 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira product discovery, jpd premium, product management, idea management, product discovery, jira premium, product planning, atlassian community, product development, roadmap planning, product prioritization, feature management

Introducing Jira Product Discovery Premium ✨

Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.

Learn more
AUG Leaders

Atlassian Community Events