Hi all,
How could I automatically change the priority of all issues where the due date is due in the next 2 weeks?
Could this be done through jelly somehow running on a service?
Thanks
Paul
You can use this script as a base for a Script Runner service.
package eventim.services
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.web.bean.PagerFilter
import org.apache.log4j.Logger
import static com.atlassian.jira.event.type.EventDispatchOption.DO_NOT_DISPATCH
Logger log = Logger.getLogger("EscalationService")
log.debug "Starting Escalation Service"
IssueService issueService = ComponentAccessor.issueService
user = ComponentAccessor.userUtil.getUserObject('jira_bot') // This has to be a user who has access to all issues
List<Issue> issues = getFilterResult("duedate < 14d AND priority not in (Blocker, Critical) and resolution = Unresolved", log, user)
log.debug "Found ${issues.size()} issues to raise priority."
issues.each {issue ->
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setPriorityId('2') // Critical
validationResult = issueService.validateUpdate(user, issue.id, issueInputParameters)
if (validationResult.isValid()) {
updateResult = issueService.update(user, validationResult, DO_NOT_DISPATCH, false)
if (!updateResult.isValid()) {
log.error "Update failed"
updateResult.errorCollection.errorMessages.each {log.error "Error Message: $it"}
} else {
log.info "Update priority of issue with ID $issue.id"
}
} else {
log.error "validationResult for ${issue.id} with user ${user} is not valid, not attempting update."
validationResult.errorCollection.errorMessages.each {log.error "Error Message: $it"}
}
}
List<Issue> getFilterResult(String jqlSearch, Logger log, User user) {
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
List<Issue> issues = null
SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
if (parseResult.isValid()) {
def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())
issues = searchResult.issues
} else {
log.error("Invalid JQL: " + jqlSearch)
}
return issues
}
Have fun!
Henning
Hi Paul,
I think this article can help you: https://confluence.atlassian.com/display/JIRA/Setting+Priority+field+value+based+on+customfield+value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can script a service using the Script Runner plugin which search for issues using e.g. a JQL search and update all found issues.
Or you could try to use jelly escalation like described here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think it's possible, but I might not be the right one to help you with this. I tried Jelly at first but switched to Groovy via Script Runner because for me it's clearer how to use the API through Groovy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks. I did look at the escalation page, but it seems to use a transition to change the status, whilst I would just like to change the priority. Is this possible?
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.
If you are using this: https://jamieechlin.atlassian.net/wiki/display/GRV/Escalation%20Service - you don't need to specify an action, just can just set the priority.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahh thanks guys. Used Jamie's way of doing it via the built in script, with some of Henning's code. How do I split karma?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you like comments, the commenter gets karma, too. :-)
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.