Anyone have any tricks or tips to easily understand what script runner scripts are doing? I am analysing a new system which has loads of legacy scripts which I need to figure out if we still need but they are not labelled well at all and I am not yet great at reading groovy. Are there any easy ways to know what's actually meant to be happening?
Oh, now that's a whole new bag of random kittens.
The short answer is "no", you're going to need to read and understand what each one is doing in quite a lot of detail.
There is some good news here though
@Nic Brough -Adaptavist- Many thanks!
As I will need to become quite good at this, I would love to get a few pointers if you would have time? Although I've only been using Script Runnner for a few months it does feel like a lot can be learnt quite quickly and it is such an amazing tool I would like to understand it better.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think the main thing is to not try to go through the detail the first time. Getting a feel for what a script is doing does not need a great understanding of each line in it. You can always come back to a complex line of code if you need to.
Scripts tend to make calls into Jira's Java API, which has javadoc These are technical, and don't have much explanation, but can be helpful if you don't know what a specific function is doing, and good coders will have used indicative names. Note that there are different sets for "the platform". (The platform effectively includes Jira Work Management), Jira Software and Jira Service Management we add on top of the platform, so everything in the platform applies the same to them.
This means you can usually rely on reading something like:
def linkedIssues = ComponentAccessor.issueLinkManager.getOutwardLinks(issue.id).findAll { it.destinationObject.issueType.name == linkedIssueType }
doing what the code's function names say. The bit in bold is pure Jira (start at issuelinkmanager if you want to read the example's docs) The variable linkedIssues will contain a list of issues linked to the issue in issue.id which are outward, and the target issue is of whatever type is in the linkedIssueType variable.
There is one thing people trip over a lot though - custom fields are complex and a lot of new scripters don't quite understand what getCustomFieldValue does. It does indeed get the value of a custom field, but that value could be in a number of different shapes. Numeric fields will return long objects, date and date/time return timestamp objects, select-lists return "options" (which are objects specific to Jira), and muti-selects return lists of options! You are likely to see code that can either cope with multiple possible types, or that people have taken the simple route - they know what the field type is already, so they can assume the content is a specific type of data.
Of course, we have documentation, including training, but it's very much aimed at solving problems with SR, not so much "how do I read and update inherited scripts" (but we're working on that)
Another resource might be https://library.adaptavist.com - if you think a script might be doing X, have a look in the library for action X - a code comparison might tell you lots!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nic Brough -Adaptavist- can you let me know what is the best way to get support from Adaptavist if I need quick help with a specific script? I was hoping to not have to paste scripts here in the community? I raised an Atlassian Request but they won't help with ScriptRunner I don't think.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are a couple of options
Raise a request at https://productsupport.adaptavist.com/servicedesk/customer/user/login?destination=portals
Or I can take a look. I'm a customer success manager now, it's my job to help people out with our products (but I've done a lot of scripting in the past, and like getting my paws dirty with code). If you'd prefer to talk to me direct, let me know. If you are the technical contact on your SR licence, then I should be able to find an email address for you in our licence list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nic Brough -Adaptavist- thanks, I raised a request SRJSUP-28721, would be good to chat direct at some point if poss, I am at the start of my scripting life and need any advice I can get especially working out what is going on with all these old pieces of code!
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.