Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Writing a custom code using Scriptrunner for Jira

Oupa Monareng September 20, 2018

Hi Guys,

I'm trying to write a post function condition using groovy scriptrunner. What I want to achieve is the following:

* When a request is created on service desk, a clone should be auto-created and linked to the main request, and then based on the Issue type selected then the clone should be moved to another project. For example if a task issue type is selected then the clone must be move to Project1 and if bug issue type is selected then the clone must be moved to Project2 and so on.

I've realized that through the built-in scripts I can achieve this, however I can only select one destination project.

 

Kind regards,

Oupa.

3 answers

2 votes
Dave Bosman [Realdolmen]
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.
September 20, 2018

Hi @Oupa Monareng

 

I am not good at scripting so i will not be able to help you with a script. 

But, there are other ways of solving it if you do not find a solution with a script. You could do it with automation for jira plugin. 

An extra advantage is that when you upgrade your jira instance, you would not need to check your script and adapt it if some function is deprecated. 

 

Regards

Dave

Oupa Monareng September 21, 2018

Thanks for your reply Dave, I will considering this plugin as a last resort simply because the costs are ridiculously expensive and since we're already using Scriptrunner I wanted to exploit the functionalities.

Dave Bosman [Realdolmen]
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.
September 21, 2018

I understand your point of view, I just wanted to give you an alternative in case you can't find a solution with the scriptrunner. 

0 votes
Daniel Yelamos [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.
October 4, 2018

As Nir said, yes, it is hard to do it with Scriptrunner. This has to do with the fact that the JIRA API doesn't offer a straightforward way of doing this.

However, it might be a lot easier to clone your issue to another project and linking it, instead of "moving the issue". You can do this by:

  1. Create a CloneIssue postfunction(which you get out of the box with Scriptrunner). This postfunction should clone the issue to your project based on your criteria.
  2. Then, you can delete the original issue. This isn't out of the box, but you can find examples of scripts in this community on how to delete an issue.

My suggestion would be that you ignore step 2, to be honest. The clone issue will link it to your original project for easy reference.

If you need any further clarification, let me know, I'd be glad to help.

Cheers

DY

Oupa Monareng October 8, 2018

Hi DY,

 

Thanks for your response, I have tried using the cloneissue postfunction which clones the original issue and then links the 2 issues, then assigns the clone to a different project, which works perfectly. The only limitation is that you can only select a single target project and in my case I need to have multiple target projects which can be associated through a selection based on a custom unique identifier or perhaps issue type.

 

Kind Regards,

Oupa.

0 votes
Nir Haimov
Community Champion
September 21, 2018

It is very hard to move issue with ScriptRunner.

I would suggest you @Dave Bosman [Realdolmen] solution with automation for jira plugin. 

Suggest an answer

Log in or Sign up to answer