Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Scriptrunner default listener "Clones an issue, and links" not working

Michiel V_ March 24, 2021

Context:

I am trying to perform some automation between our Jira Service Desk and the Jira Projects of our teams using Adaptavist Scriptrunner. I'm new to the tool so I'm trying to stick with the default functions that are provided by Scriptrunner.

Goal:

My goal is to clone, move and link a service desk ticket to different jira (software) project when a specific event is triggered.

(Attempt at) execution:

I am trying to accomplish this using the default or preset Scriptrunner function "Clones an issue, and links". Which more or less does exactly what I need. here is some information about the function.

I set up the listener with data that I have triple checked by now, and have also tried to tone down in complexity to make sure that nothing was getting messed up in the "Condition" or "Additional issue actions" script fields. 

Test:

I manually trigger the event by changing the status of some tickets in the Service Desk. I expect to see a linked issue to be created in the backlog of the targeted project. 

Result:

No linked issue shows up on the Service Desk ticket of which I just changed the status. Refreshing the page also shows no change. When manually checking the backlog of the targeted project, I see no new issues that were created via the clone/move that I would expect.

When I check the listener in the Scriptrunner app, it always shows me that there were no failures with the last X amount of executions.

 

2021-03-24 12_30_09-Listeners.png

So it seems that either the listener IS executing, but I have no idea what it is actually doing. Or that something is wrong with the listener and that it is not doing anything at all but still showing that the exectution is ok.

There is very little information available to me to go and investigate what this listener is actually doing or trying to do behind the scenes. There is some Payload data available when I check the Execution data in the History column shown in the image above, but this just gives me a bunch of info about the Service Desk ticket on which i triggered the event.

I have no idea how to find out what I am doing wrong, If I'm doing anything wrong at all. Does anyone have any experience with this sort of thing? 

Thanks in advance.

 

Jira Service Desk version; 4.3.1

Jira Software version; 8.3.1

Scriptrunner version: 6.21.0

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 24, 2021

Can you include some screenshots of your configurations?

Are you positive that the last field in the form is correctly populated: Issue Link Type / Direction

If you leave that blank, no links are created between the original and cloned issue.

If that's correct but you still don't get links, make sure the "run as" user has permission to create links.

The logs area in the execution history will only show logs that you manually output using log.info("some text") either in the condition or in the additional action blocks.

Michiel V_ March 24, 2021

Hi Peter-Dave,

I am positive that the last field was filled out. I have also checked but there aren't even any issues being created in the target project, so there is nothing to be linked.

I am Jira Admin of our entire server at the moment (as of recently so I am not very experienced yet) and I should have all the necessary rights to move/clone/create issues. When I navigate to the relevant projects I am able to perform these actions manually so that confirms it.

Some screenshots and extra info below.

 

Clone_And_Link_Listener_1.png

 

Clone_And_Link_Listener_2.png

 

The two screenshots above show the configuration of the listener. There was a bunch of codes in the "Conditions" and "Additional issue actions" fields earlier but I scrapped all of it to be sure that these are not causing the issues.

Target_Issue_Type.png

 

Event_Trigger.png

 

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 24, 2021

I've only used this configuration directly in a workflow post function.
Since you are only firing on a single project and workflow event, that might be a better place for it.

But I would try to add the following to condition (just to be sure)

log.info "Evaluating condition for Move to Pending Event: $event.issue"
true

That might give you some clues.

What I'm wondering right now is if this type of built-in script knows how to handle custom events (as yours clearly is). I've worked mostly with system events.

Or, the custom event is not loaded with an issue object and the built-in script doesn't have anything to act on.

You can troubleshoot that by creating a separate custom event and outputting to the log some of the objects bound to the custom event.

But if the built-in script can't work on the custom event, your best bet will be to move the config to the workflow postfunction.

Michiel V_ March 25, 2021

Alright so I've been trying a few more things.

Yesterday evening we had to reset our server because of reasons. Since the server reset, the Listener does seem to work but only if i leave the "Condition" field blank.

When I add my desired condition (which is a component check) it does not run.

log.info "Evaluating condition for Move to Pending Event: $event.issue"
issue.components == 'Jira Service Desk'

Note that I added the log.info line as you suggested, but this does not seem to provide any log info at all. As shown on the screenshot below;

logs_with_log_code_line.png

However, when I trigger the Listener when the Condition field is blank (not even the log.info line is in there), the logs do return something. Note that the Listener is working in this case even though this log message shows up.

2021-03-25 18:28:00,290 WARN [servicedesk.ServiceDeskUtils]: Failed to retrieve service desk for KLVV: The Service Desk you are trying to view does not exist.

 

This leads me to believe that something is wrong with my (very simple) condition.

issue.components == 'Jira Service Desk'

The compared value matches the Component label set on the ticket which I used for testing perfectly. Is something else wrong with this Conditional check?

JiraServiceDesk_Component.png

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 25, 2021

That's mysterious...

 

Regarding component condition... try

issue.components.any{it.name == 'Jira Service Desk'}

//or

issue.components.every{it.name == 'Jira Service Desk'}

That's because issue.components should return a list of ProjectCopmonent objects. you want to compare the name of those objects.

Michiel V_ March 26, 2021

Hi Peter-Dave,

I tried

issue.components.any{it.name == 'Jira Service Desk'}

and now it works like a charm! Thank you very much! 

TAGS
AUG Leaders

Atlassian Community Events