Hello,
I need assistance with Scriptrunner for Jira cloud. In the past, I have done Scriptrunner customization on Jira Server but never used the cloud version. I am looking into the REST API documentation, but would appreciate some help to kick start and get the hang for how it works.
This is what I am trying to do -
As part of "Deployment" Issue, "Deployed" status Post-transition, I want to get the associated FixVersion field value. Then, want to get the list of all Agile Issues that are linked to the same FixVersion. For each of those Agile Issues, I want to auto-transition those that are in "Development Completed" status to "Ready for Testing" status and ignore the rest.
Thanks in advance.
Venkat
Hi Venkat,
Thank you for your question.
I can confirm that the way that Jira Cloud works is different to Jira server as there is only a rest API for the cloud version and no Java API as described in the documentation here.
In order to achieve this requirement you would need to create a script which performs a JQL search in order to identify all issues which macthed the specified fix version, and then for each of those issues to loop over each issue returned and only transition the ones which match a specified issue type and status.
I have created an example of a script which can be ran on the script console inside of ScripRunner for Jira cloud to show how this can be done which is located here.
You will be able to use this script in order to show how you could create a similar script as a post function or a listiner to transition the required issues.
Please not that when executing a transition a script will only be able to transition the issue if the transition to the required status from the current status exists inside of the workflow.
If this issue has solved your requirement can you please mark it as accepted so that other users can see it is correct when searching for similar answers.
Regards,
Kristian
Hi Kristian,
Thanks a lot for your time. Your script is very clean and precise and gives a nice structure that I can follow in my future scripts.
Earlier today, I came up with a working script (combination of documentation and other Atlassian answers :)) that is pretty close to yours. This is working as Post-Function script on the "Deployment" Issue type.
def issueKey = issue.key
String fixV = get("/rest/api/2/issue/${issueKey}").asObject(Map).body['fields']['fixVersions']['name']
def fixVer = fixV.replaceAll("\\[|\\]","")
Map<String, Object> searchResult = get('/rest/api/2/search')
.queryString('jql', "fixVersion = ${fixVer} AND project = XYZ AND issuetype != 'Deployment Request' AND status = 'Development Completed'")
.queryString('fields', 'project')
.asObject(Map)
.body
def issues = (List<Map<String, Object>>) searchResult.issues
for(issue in issues)
{
def res = post("/rest/api/2/issue/" + issue["key"] + "/transitions")
.header("Content-Type", "application/json")
.body([
"transition": [
"id": "51"
]
])
.asString()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Venkat,
Thankyou for confirming that you managed to create a working solution.
Could you please mark the answer as accepted so that other users searching for searching a similar question can see that this script contains a correct answer which they can use.
Regards,
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kristian,
For some reason, I dont see the "Accept Solution" check mark. Please see attached.
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ventak,
Normally it would be directly below the answer but I cannot see what options below the answer form your screenshot.
Kristian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Should be even more to the left of that blue up-arrow than everything else on the screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the past, when I was using different Atlassian account, I have accepted answers. It must be something to do with my current account. I dont see the check mark at all (Please see screenshot attached). This is my first post using this account.
Nic, do you mind accepting Kristian's answer?
Thanks.
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.