Prevent user from moving ISSUE between all states

Casey Daniell November 13, 2015

In our Orig we are trying to avoid formal roles like DEV and QA. Is it possible to use Scriptrunner to control transitions between statuses, and prevent the same person from moving an ISSUE between all statuses. 

For example, I want DEV A to move a STORY to RESOLVED, but not the next state of VALIDATED, which he must ask DEV  B to do after checking his work. In another ISSUE though DEV B may move the ISSUE to RESOLVED, and DEV A QA's the work moving it to VALIDATED.

Ideally, it's a very simply JQL query to determine who moved the ISSUE to one RESOLVED and prevent that same user from moving it to VALIDATED too. 

(I know we can do this by assigning users to static roles then only allowing users in a role to perform the transition – this isn't what I want to manage)

3 answers

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 15, 2015

You could put the following code as a simple scripted condition on the Validate action:

import com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeHistories = changeHistoryManager.getChangeHistories(issue)

def currentUserKey = ComponentAccessor.getJiraAuthenticationContext().getUser()?.key

// returns true if there are no transitions to the target state by the current user
passesCondition = ! changeHistoryManager.getAllChangeItems(issue).find {
    it.field == "status" &&
        currentUserKey == it.userKey &&
        "Resolved" in it.toValues.values()
}
0 votes
Geoff Wilson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 13, 2015

You may have already seen this, but in a Workflow's Transition's Condition you can select one of these, such as "Only Reporter Condition" so that only allow the reporter to execute this next transition (ex: if your DEV A wrote a Task and DEV B worked on it, only DEV A can set the next workflow transition to say Completed once they review it).

Add Condition To Transition

 NameDescription
Transition to execute only if code has/has not (depending on configuration) been committed against this issue.
Condition to hide a transition from the user. The transition can only be triggered from a workflow function.
Transition to execute only if there are no related open Crucible reviews.
Condition to allow only the assignee to execute a transition.
Condition to allow only the reporter to execute a transition.
Condition to allow only users with a certain permission to execute a transition.
Runs a script to evaluate whether to allow this action, or a built-in script.
Condition to block parent issue transition depending on sub-task status.
Transition to execute only if there are no unreviewed changesets related to this issue.
Allows only users of a given group to execute the transition.
Allows only users of a given role to execute the transition.
Allows only users in a given custom field to execute the transition.
Condition to allow only users in a given group to execute a transition.
Condition to allow only users in a custom field-specified group to execute a transition.
Condition to allow only users in a given project role to execute a transition.
Allows to execute a transition if the given value of a field is equal to a constant value, or simply set.
0 votes
James Strangeway
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 13, 2015

You can add a "separation of duties" condition to the transition of the workflow.  This is built in and should get you what you are looking for.

 

Hope this helps.

Cheers!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events