I have just started using Scriptrunner on Cloud. I have been using the DC version, and would like to see how the scripting differs between the two.
We have a script that updates the fix version of sub-task when parent fix version is updated. I am trying to recreate this in Cloud , but nothing seems to work.
Can I please get some help on how this could be achieved.
Below is the DC script:
IssueManager issueManager = ComponentAccessor.getComponent(IssueManager.class)
Issue updatedIssue = event.getIssue()
Collection<Version> fixVersions = new ArrayList<Version>()
fixVersions = updatedIssue.getFixVersions()
Collection<Issue> subTasks = updatedIssue.getSubTaskObjects()
subTasks.each {
if (it instanceof MutableIssue) {
((MutableIssue) it).setFixVersions(fixVersions)
issueManager.updateIssue(event.getUser(), it, EventDispatchOption.ISSUE_UPDATED, false)
}
}
Hi @Aisha M
If you are using ScriptRunner for Jira Cloud, just like for DC, you can use HAPI for Jira Cloud and simplify your coding.
Below is a sample working code for your reference:-
def currentIssue = Issues.getByKey(issue.key as String)
if (currentIssue.isSubTask()) {
def parent = currentIssue.parentObject
currentIssue.update {
setFixVersions {
add("${parent.fixVersions.last()}")
}
}
}
Please note that the sample working code above is not 100% exact to your environment. Hence, you must make the required modifications
For more information on ScriptRunner's HAPI for Jira Cloud, please refer to this documentation.
I hope this helps to answer your question. :)
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_ , Let me try the sample script.
But there is a condition being required for the Listener to work. What would be the most appropriate one for our scenario ?
I tried ,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aisha M
Please clarify: are you trying to add the condition to identify the parent issue type?
If yes, then you should do:-
def currentIssue = Issues.getByKey(issue.key as String)
if (currentIssue.isSubTask()) {
def parent = currentIssue.parentObject
if (parent.issueType.name == 'Story') {
currentIssue.update {
setFixVersions {
add("${parent.fixVersions.last()}")
}
}
}
}
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Aisha M
Switch to Automation instead of ScriptRunner in this case.
You can simply do the following:
Trigger = "Value changed" on edit (Fix Version)
Branch rule: on all children
Edit work-item: Fix-Version Copy from current work-item.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@arielei Thank you for the reply
I can understand that automation could be an easier option. But I really want to understand how the scripts differs between the two, because we have a huge amount of scripts that needs to be adapted to suit the cloud environment.
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.
Hi ! At this point, we are trying to explore the different options with Cloud. If nothing works out, maybe we might look into Automation.
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.