// Check if ticket is assigned to a user
// -- If not, check that the user has the assignable user permission
// ----- If they do, assign it to the current user
if (issue.fields.assignee != null) {
//Set assignee here,
def issueKey = 'AAA-111111'
def result = get('/rest/api/2/issue/' + issueKey + '?fields=assignee')
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status == 200){
if (result.body.fields['assignee'] == null) {
def put = put('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.body([
fields:[
assignee: [
id: 'admin'
]
]
])
.asString()
if (put.status == 204) {
return 'Success'
} else {
return "${put.status}: ${put.body}"
}
}
} else {
return "Failed to find issue: Status: ${result.status} ${result.body}"
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sure,
def result = get('/rest/api/2/issue/' + issueKey + '?fields=assignee')
this get only the "assignee" field data (no need to get all data if all you want is the assignee)
inside you got "if" statement, status 200 says "success"
so if success to get the assignee data of the issue, check if it null
if (result.body.fields['assignee'] == null)
if it is null, put (update) the assignee that you want (in my example i set 'admin'), you change the assignee to who ever you want.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nir Haimov if I want the user who executed the transition to be set as the assignee is that the current user? How would I do so?
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.
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.