Forums

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

Jira ScriptRunner: Access inline behaviour from custom endpoint

Tom McCluskey May 18, 2018

We've got an inline behaviour set up that assigns some custom fields based on the values put into other custom fields; for example, it's assigning issues for a certain client to a certain team. I've just gotten a request to automate some issue creation, which I can do with the Jira API fairly easily. However, since the team field is set in a behaviour, it is not set when issues are created via the API.

The complication here is that I do not have permissions to the file system where Jira is, so (as far as I know) I can't do anything other than inline scripts.

Is there a way that I can write a custom endpoint that would respond with the information in the inline behaviour so that I could then assign issues to the correct team based on the client? If not, is there some other option I'm overlooking, or is my only option to get permissions to the file system in question?

Thanks!

2 answers

0 votes
Tom McCluskey May 21, 2018

Ah! That makes sense, thanks. I'll check it out and see how it goes. Much obliged!

0 votes
Alexey Matveev
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.
May 18, 2018

Hello,

The inline code, which you develop for behaviours, is execute on your Jira server, that is why you can use Java Api there.

Tom McCluskey May 21, 2018

Hi Alexey,

Thanks, that's great to know. Does that mean that I have access to variables defined in the behaviour from a custom endpoint? If so, how do I go about accessing them?

Alexey Matveev
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.
May 21, 2018

You can call your custom rest point from the behaviour and pass all variables, defined in the behaviour to your rest endpoint.

Tom McCluskey May 21, 2018

I want to go the other way, though: I need the behaviour to work on issue creation, and then I also need to have a custom endpoint return the information in the behaviour. Can you tell me the syntax to do that?

 

Thanks!

Alexey Matveev
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.
May 21, 2018

You can not call a behaviour from a rest endpoint. But you can call a rest endpoint from a behaviour. When your behaviour works on the create issue screen, it can call a rest endpoint to get info from the rest endpoint. Here is an example:

https://community.atlassian.com/t5/Answers-Developer-Questions/Making-a-REST-call-using-script-runner/qaq-p/576712

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events