Automatic migration between Server/Data Center and Cloud does not exist due to the differences in the programming model and the API. The process of migration involves analyzing the desired functionality and translating that into the target platform.
Jira Cloud uses the Atlassian Connect framework to allow add-ons like ScriptRunner to provide additional functionality, whereas Jira Server/Data Center use the Atlassian Plugins framework, known as Plugins v2, or P2. There are fundamental differences between Connect and P2 that directly impact ScriptRunner functionality and script writing, the main ones are outlined in the table below:
Table 1. Platform Differences
Java API - it is possible to call almost any of the Host application code directly. Plugins are running in the same JVM as the host application.
REST APIs are available to interact with the host application. Connect has access to a limited set of REST APIs as defined by the Product API Scopes, this means that Connect add-ons can only do things officially supported by the APIs, but it also means that APIs are less likely to change and add-ons are less likely to break as a result.
In the same JVM as the host application. Events can be vetoed and code runs synchronously. A bug in add-on code can seriously affect application stability or performance.
Asynchronous. Runs as a completely separate service. No code runs in the same JVM as the host. Events are processed as webhooks that fired from the host and processed asynchronously by the add-on - no waiting for events to be processed. A failing add-on does not impact the performance of an Atlassian application (although functionality may be missing).
Authentication and Authorization
Code can run as any user in the system including as no user (which is not the same as Anonymous). Authentication and authorization can be bypassed.
Add-ons make requests as the add-on user or the user that initiated the interaction. It is not possible to bypass authorization or authentication
In summary, there are significant differences between the Connect and P2 frameworks and it is necessary to re-think how ScriptRunner scripts execute and interact with the host application when moving from Server/Data Center to Cloud, or Cloud to Server/Data Center.
The asynchronous nature of Connect has implications with regards to host interaction, for example, in Jira it is not possible to implement event listeners that prevent event processing. Similarly when writing ScriptRunner scripts for server hosts, it is important to consider the impact that scripts will have, particularly when interacting with external systems that might be slow.
As with most programming situations there are trade offs when writing scripts for both Cloud and Server/Data Center and the limitations of Cloud are at the expense of stability and performance of the Atlassian application.