Prevent user from moving ISSUE between all states

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

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()
}

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!

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.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Jul 10, 2018 in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

173 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you