Create Issue in Jira

Nitu Kumari January 23, 2020

Hi All,

 

I want to create issue in jira script runner using Rest Api in groovy. Anybody can please help?

2 answers

1 vote
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.
January 23, 2020

Could you tell us what you are trying to do?  Not how, but what?

Problem is you've said "create issue in Jira SR using REST API" - if you have SR, you don't need to use REST, you have direct access to the Jira you are in.  But you might also mean you're trying to create issues from somewhere else (in which case, you might not need SR, as Jira has a REST interface). 

We can clarify what the question is and hence get started on a proper answer.

Nitu Kumari January 23, 2020

Hi Nic,

 

The requirement is when  an issue of type Risk is moved to the workflow state of 'Occurred' then validate whether any issue of type "issue" is linked with the parent issue t "Risk", if yes then nothing will happen if no then we need to create an issue of type issue, and the Summary,description from the Risk is used as the Summary,description of the Issue.

I am trying to write the groovy script in validator custom script.

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.
January 27, 2020


Ok, so nothing to do with REST.

I would do this with a post-function. You should NEVER try to make changes to anything in a validator - a validator is part-way through a process and should only ever say "yes, this is ok", or "no, your data does not fit, so we will not be proceeding with the transition". If you were to put issue updates in a validator, you will start finding them doing very odd things and possibly trashing your database.

So, a post-function on the "go to occurred" transition of the Risk workflow would need to
Go through the links on the current issue
Check if the far end is of type "issue"
If you cannot find one, then create one, copying summary and description from current issue

These two should help you put together code for that:
https://library.adaptavist.com/entity/check-for-duplicate-link-when-resolution-is-duplicate
https://library.adaptavist.com/entity/automate-the-creation-of-an-issue-in-jira

0 votes
Stephen Wright _Elabor8_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 23, 2020

Hi @Nitu Kumari

It depends on what kind of scenario you're scripting for.

I would suggest starting on Scriptrunner's wiki - click here to view it - you could achieve this with a listener or post-function, both of which have instructions and examples within their wiki :)

Ste

Suggest an answer

Log in or Sign up to answer