How to add a custom button which will trigger a groovy script not as part of a workflow

Adiel Segal March 12, 2020

Hello,

 

I'm trying to create a button that will trigger an external script (by using Groovy inline script).

I want this button not to be based on a transition within the WF itself, but as a standalone button, that will be able to be processed only if various conditions will be met.

After I've investigated the issue I understood that the solution can be achieved by creating a Custom web item (via Script Fragments of ScriptRunner) that will trigger a custom Rest endpoint in which my Groovy script will be written, but when I did that I realized that some of the class which I'm wishing to use are unavailable (e.g. import com.atlassian.jira.issue.fields.Field
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption)

 

Am I going in the right direction? or there is a different recommended best practice in order to achieve my goal?

 

Thanks,

Adiel

 

 

2 answers

0 votes
Adiel Segal March 18, 2020

Any other suggestions? someone? 

ragipally alekya July 17, 2020

hey @Adiel Segal what have you used in the end? ScriptFragments?  Have you done it successfully?

0 votes
Krishnanand Nayak
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.
March 12, 2020

Just trying to understand ... are you trying to do some issue related task when the button is clicked?

Adiel Segal March 12, 2020

Not exactly. basically when the button is clicked the inline Groovy script is calling an external Python script that runs in the background.

At the end of the Python script execution, an HTML file is being attached to the original Jira issue from which the process was initially triggered. 

Krishnanand Nayak
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.
March 12, 2020

you can try setting the context issue. not sure it will help to what you are trying to do.

def issue = context.issue as Issue

Adiel Segal March 12, 2020

Thanks @Krishnanand Nayak , but I'm receiving the following error: 'The variable [context] is undeclared'

Krishnanand Nayak
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 17, 2020

@Adiel Segal have you made any progress on this or have a script that will explain what you are trying to do?

Suggest an answer

Log in or Sign up to answer