Tutorial for script runner

Paul DeSousa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2014

Anyone know where to find a tutorial on script runner?  It looks like exactly what we need but being new to JIRA.

2 answers

8 votes
Alejo Villarrubia [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2015
kunti pawar May 7, 2018

now I am opening above link, but page does not exist, anybody can help me?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 8, 2018

It's nearly 3 years old, and people have moved on.  Have a look at the SR docs and search this community for what you're trying to achieve.

kunti pawar May 8, 2018

Hi Nic Brough ,

Thanks for reply,

Now I am able to looking script runner in jira.

But I need help for the retrieve issue id using scriptrunner

Could you please help me when you get free time

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 9, 2018

How you retrieve an issue id depends on where you are running the script.  If it's in the console, you'll need to use an issueManager to fetch the issue.  If you're in a transition then the object simply called issue is immediately available to your scripts, and so-on.

Like Manga Man likes this
Dennis Alexander June 6, 2019

so is there any document that outlines this?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 6, 2019

https://scriptrunner.adaptavist.com/latest/index.html will take you to the relevant docs

Like senthilkumar sellakani likes this
Dennis Alexander June 6, 2019

Look

https://scriptrunner.adaptavist.com/latest/jira/scripted-fields.html#_scripting

https://scriptrunner.adaptavist.com/latest/jira/builtin-scripts.html#_technical_stuff_for_advanced_users

 

see a couple of bindings (quick starting points) could be used in different scenarios

 

It would be nice to have a table of what bindings I can use in different scenarios

Console these bindings

Built-in scripts: these bindings

Transition scripts: these bindings

Scripted fields: these and so on

It's kind of painful to learn from other people scripts and mostly it's a guesswork

 

For example, Scripted Fields does not mention that issue is available as a binding. Perhaps it is obvious, but a clear map of what binding(shortcuts) are available where would be probably the most popular page on Adaptavist web site.

Paul DeSousa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2014

Thanks Michal, but I was looking for something a bit more basic (Start me with a hello world :). Being new to JIRA, I do not even know where to start. I started writing plugin but that will take some time and to solve the immediate need of having a script that will automatically put the project into the correct component. Cheers...

Paul DeSousa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2014

When I try to run any example I get every line as an error: Error!startup failed: Script1.groovy: 1: unable to resolve class ComponentManager @ line 1, column 18. ComponentManager componentManager = ComponentManager.getInstance() ^ Script1.groovy: 2: unable to resolve class User @ line 2, column 6. User remoteUser = componentManager.getJiraAuthenticationContext().getUser() ^ Script1.groovy: 3: unable to resolve class MutableIssue @ line 3, column 14. MutableIssue issue = componentManager.getIssueManager().getIssueObject("DTT-1757") ^ Script1.groovy: 4: unable to resolve class Project @ line 4, column 9. Project project = issue.getProjectObject() ^ Script1.groovy: 5: unable to resolve class Version @ line 5, column 9. Version version = componentManager.getVersionManager().getVersion(project.getId(), "1.2") ^ Script1.groovy: 6: unable to resolve class ProjectComponent @ line 6, column 18. ProjectComponent component = componentManager.getProjectComponentManager().findByComponentName(project.getId(), "MyComponent") ^ Script1.groovy: 11: unable to resolve class ActionResult @ line 11, column 14. ActionResult aResult = CoreFactory.getActionDispatcher().execute(ActionNames.ISSUE_UPDATE, actionParams); ^ 7 errors

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2014

Are you trying to do this in confluence, or was that just a "tagging failure"?

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2014

Assuming you did mean jira, seems like you are missing an import: import com.atlassian.jira.ComponentManager

Paul DeSousa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2014

Thanks Jamie, and yeah I am doing 100 things on both JIRA and confluence. This is a JIRA thing, apologies. OK yeah that is why I really would like a how to like the develop your own plugins. Thanks I will try that (tomorrow as it is late in the East :)

Paul DeSousa
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 14, 2014

OK That fixed the first line error, I probably just need more imports as I just copy pasted: https://jamieechlin.atlassian.net/wiki/display/GRV/Post+Functions#PostFunctions-SetAffectsVersions,FixVersionsorComponents which has no imports. It may help users if you post the imports in that block of code just like the other ones have. Just my two cents...

Daniel Luevano July 9, 2015

@Paul DeSousa Did you find that tutorial? I would be really useful this time for me, thanks!

Suggest an answer

Log in or Sign up to answer