Working of Remote Control and Remote Events for a new user to script runner.

Can you help me evaluate Remote control and Remote events, i have followed the doc :https://scriptrunner.adaptavist.com/5.2.2/jira/remote-events.html

but i find it very complex to understand its example and use cases , can i get a better way of information to replicate its use cases on my local server ??

specially the remote events versioning code given has errors, i have no knowledge where to put the code either om local or remote server. 

so can you give me more clarity to replicate what Remote Control and Remote Events can do ?

1 answer

0 vote
Alexey Matveev Community Champion Jan 12, 2018

Hello,

I did not find it explicitly in the documentation but ScriptRunner must be installed on the local and remote instances. It will not work if one of the instances does not have the right version of Scriptrunner

Remote Events let you recieve events from another Atlassian application (Jira, Confluence, Bitbucket). Suppose you want to create an issue and assign it to the right person if a repostitory in bitbucket was created. You can create a remote event in Jira and link it to the repostiory created event in your Bitbucket instance. You would paste the code into your created remote event in Jira. The code would be triggered by Scriptrunner for Bitbucket when the create repository event fired in Bitbucket.

Remote Control lets you execute code in remote instances. It is just a library from Scriptrunner which you can use in your code.

Hello,

Can you please give me a reference between two JIRA servers, what Remote Control and events can do for two jira servers ??

 

thanks.

Alexey Matveev Community Champion Jan 14, 2018

These are the links

https://scriptrunner.adaptavist.com/latest/jira/remote-events.html

https://scriptrunner.adaptavist.com/latest/jira/remote-control.html

I could not find any documentatin which would describe remote events for two Jira Servers. But you can catch any event in the remote Jira and fire your own routine. Maybe you will tell me what you need to do and I will tell you if it can be done.

why do i get errors when i execute the "Example: Synchronize JIRA Versions" in Remote events documents page, code on my script console ?

Also how to achieve :

  1. Provisioning - when a project is created in JIRA, create it also in Bitbucket and Confluence.

  2. Synchronise JIRA versions between instances - when you create a version in one JIRA instance it appears in another

  3. When a JIRA version is created, automatically create a page in Confluence

with Remote events ? what is the code or proedure to execute them ?

Hi 

Could you please reply on this issue ?

Thanks.

Alexey Matveev Community Champion Jan 22, 2018

The problem is that I can not provide you with the code but I can give you a couple of hints

1. Provisioning - when a project is created in JIRA, create it also in Bitbucket and Confluence.

You do not need Remote Events here. You can create a usual listener in Jira which would fire on ProjectCreatedEvent. Then you would use REST API in your listener to create a project in Bitbucket and a page in Confluence

https://docs.atlassian.com/bitbucket-server/rest/5.7.0/bitbucket-rest.html#idm45568366071360

https://developer.atlassian.com/cloud/confluence/rest/#api-content-post

Or you could use Remote Control to create a confluence page with Confluence JAVA API and a project in Bitbucket using Bitbucket Java API.

2. Synchronise JIRA versions between instances - when you create a version in one JIRA instance it appears in another

You could make remote listeners in both Jira instances which would listen to VersionCreateEvent. Then in those listeners you would create a new version if such version does not exist in the current instance using Jira Java API.

3. When a JIRA version is created, automatically create a page in Confluence

You do not need a remote event. You could write a usual listener which would fire on VersionCreateEvent and then you could create a page in Confluence either using Confluence REST API or using remote control to create a page with Confluence Java API. 

 

Those are an interesting tasks to accomplish but unfortunately writing the code would take too much time. Hopefully it helps!

Thanks Alexey Matveev,

I usually get this error, "The variable [event] is undeclared" in this code. Can you please help ?

log.debug JsonOutput.prettyPrint(JsonOutput.toJson(event))

line of code taken from "Example: Synchronize JIRA Versions"

https://scriptrunner.adaptavist.com/5.2.7/jira/remote-events.html#_example_synchronize_jira_versions

Alexey Matveev Community Champion Jan 22, 2018

Could you provide a screenshot with the error?

Alexey Matveev Community Champion Jan 22, 2018

This script must be in a remote listener. Are you sure that the script is there? Could you provide the whole window with the configuration?

Even there the error is same.

sr2.png

 sr2.png 

Alexey Matveev Community Champion Jan 22, 2018

As far as I can see from your code the line log.debug JsonOutput.prettyPrint(JsonOutput.toJson(event)) does not have errors. The error is in the if statement, could you provide the error? I think the problem is with the version property.

yes exactly, error at version property :

no such property version for class com.atlassian.jira.event.issue.IssueEvent

Alexey Matveev Community Champion Jan 23, 2018

I see. It could be just a static compilation error. You can create the remote listener and then create a version and have a look if there are any errors in your log file.

Or we can wait until someone from Adaptivist will see the ticket.

Or you can make a new question with your script and the error.

Unfortunately right now I can not confirm if it is a bug or a feature.

Still doesn't work .

thanks Alexey Matveev

@shaik zubeer

By the way I noticed that there is no VersionCreateEvent in your remote listener configuration. You must catch VersionCreateEvent. Kindly try to leave only VersionCreateEvent. Remote event must be VersionCreateEvent

I put only version created event and still the error persists.

Could you add to the import section

import com.atlassian.jira.event.project.VersionCreateEvent

and then the first line after the import section

def event = event as VersionCreateEvent

Thanks Allot Matveev,

I am unblocked on the previous error.

Have got another one, 

sr3.png

no such property userStartDate (also userReleaseDate) in class:

com.atlassian.jira.project.version.Version.

Alexey Matveev Community Champion Jan 23, 2018

change userStartDate to StartDate and userReleaseDate to ReleaseDate

Thanks For all the help Matveev,

i have proceeded further, i have created custom listeners on both the servers, when i create a version on server2 projectA , i get error in listener in server1 

2018-01-24 12:41:26,481 ERROR [runner.AbstractScriptListener]: *************************************************************************************
2018-01-24 12:41:26,481 ERROR [runner.AbstractScriptListener]: Script function failed on event: sr.com.atlassian.jira.event.project.VersionCreateEvent, script: com.onresolve.scriptrunner.canned.jira.workflow.listeners.JiraRemoteCustomListener
java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
 at Script162.run(Script162.groovy:9)
 at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runScriptAndGetContext(ScriptRunnerImpl.groovy:155)
 at com.onresolve.scriptrunner.runner.ScriptRunner$runScriptAndGetContext$3.callCurrent(Unknown Source)
 at com.onresolve.scriptrunner.runner.ScriptRunner$runScriptAndGetContext$3.callCurrent(Unknown Source)
 at com.onresolve.scriptrunner.runner.ScriptRunnerImpl.runStringAsScript(ScriptRunnerImpl.groovy:143)
 at com.onresolve.scriptrunner.runner.ScriptRunner$runStringAsScript$6.call(Unknown Source)
 at com.onresolve.scriptrunner.runner.ScriptRunner$runStringAsScript$6.call(Unknown Source)
 at com.onresolve.scriptrunner.canned.jira.workflow.listeners.CustomListener.doScript(CustomListener.groovy:120)
 at com.onresolve.scriptrunner.canned.jira.workflow.listeners.JiraRemoteCustomListener.super$2$doScript(JiraRemoteCustomListener.groovy)
 at com.onresolve.scriptrunner.canned.jira.workflow.listeners.JiraRemoteCustomListener.doScript(JiraRemoteCustomListener.groovy:28)
Caused by: java.lang.ClassNotFoundException: groovy.lang.GroovyObject
 ... 10 more

Have named "Project A" as the name of the Project in both servers, also have kept notice of ProjectID and provided same KEY's in the code , how to move further to create a version in local instance ?

Thanks For all the help Matveev,

i have proceeded further, i have created custom listeners on both the servers, when i create a version on server2 projectA , i get error in listener in server1 

sr4.png

Have named "Project A" as the name of the Project in both servers, also have kept notice of ProjectID and provided same KEY's in the code , how to move further to create a version in local instance ?

Alexey Matveev Community Champion Jan 23, 2018

To tell you the truth I have no idea about the error:)

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

826 views 2 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you