I need help with updating scripts for Scriptrunner for Jira upgrade

I have scripts that I did not create in JIRA that need to be updated for the JIRA 7 migration. I don't know Groovy. I was wondering if there is someone that can walk me through one of the scripts so I can understand what the changes are and how to test the script. Here is one of the scripts:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.mail.Email
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.server.SMTPMailServer
import java.text.DateFormat
import groovy.time.TimeCategory
ComponentManager componentManager = ComponentManager.getInstance()
MailServerManager mailServerManager = componentManager.getMailServerManager()
SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer()
if (mailServer) {
    def x = getCustomFieldValue("Severity")
    def msg = ""
    def today = new Date()
    def plainFormatter = DateFormat.instance
    def created = issue.getCreated()
    use( TimeCategory ) {
        switch (x) {
            case 'Code Red':
                msg = created + 3.days
                break
            case 'Critical':
                msg = created + 7.days
                break
            case 'High':
                msg = created + 7.days
                break
            case 'Medium':
                msg = created + 7.days
                break
            case 'Low':
                msg = created + 21.days
                break
            default:
                msg = ""
        }
    }
}

1 answer

0 vote

The first tip is to use the \{code\} macro, that makes it much easier to read.

I don't see any particular problem with this script field, other than some of the variables aren't used. Doesn't it work?

Pretty much everything you need should be at https://scriptrunner.adaptavist.com/latest/jira/releases/UpgradingToJira7.html

 

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
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

93 views 0 1
Join discussion

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