Skip to end of banner
Go to start of banner

Migrating Scripts

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Migration method

If a tool such as the Jira Cloud Migration Assistant (JCMA) or the Configuration Manager for Jira (CMJ) is used to migrate from Data Center to Jira Cloud we can assume a number of things that will make the migration more successful:

  • Project and issue type names will be identical between DC and cloud - this will ensure that project keys or issue types names used directly in scripts will continue to operate after migration

  • Custom field names will be identical - Custom field id’s will definitely not be identical. However, if SIL aliases were used (a best practice) then by updating the SIL aliases settings in cloud the scripts will automatically work with the new id’s. If custom field aliases were not used then this migration is a good opportunity to convert to using them.

  • Status and transition names (etc.) will be identical - this will ensure that any scripts using status names, transition names or id’s should continue to operate after the migration

If JCMA or CMJ is not used in the migration scripts can still be migrated by uploading them to the SIL manager or using the Self Help menu and then by configuring them manually.

Post migration testing

If a script passes the syntax check from the SIL Manager it means the following:

  • The functions used in the code are compatible between DC and cloud

  • The syntax of the script it correct

  • Custom field id’s are correct or have been updated in the alias file

What it does not mean:

  • That the script will operate exactly the same between DC and cloud

The reason that the scripts may not operated exactly the same between DC and cloud has to do with the information that may be contained in the script. Project names, issue type names, JQL queries, (etc.) may have to all be adjusted in order to guarantee the script will operate as expected. Using a migration tool will increase the likelihood of success.

We recommend that scripts will need to be tested post migration for the reasons mentioned above.

Which scripts will migrate from DC to Cloud

 Click here to expand...
Unable to render {include} The included page could not be found.

Scripts that will need changes when migrating

Conditions and validator scripts

Conditions and validators are written using a language/syntax called Jira Expressions in the cloud. All truly scripted conditions and validators are not supported in Cloud at this time. Many people find using Jira Expressions to be difficult and time consuming. Like other features in Cloud, the solution may be to look at the problem in a slightly different way and to tweak the solution. See this article for a solution to continue using SIL scripted conditions and validators in Jira Cloud.

 Jira Expressions example
issue.issueType.name.match('^(Dev Task)$') == null || 
(issue.issueType.name.match('^(Dev Task)$') != null && 
issue.parent.subtasks.filter(subtask => subtask.assignee != null).length == 
issue.parent.subtasks.length)? true : false
 SIL plus Jira Expressions example
//SIL code
boolean passConditionValue = true;
if(issueType == "Dev Task") {
    for(string s in subtasks(parent)) {
        if(s.issueType == "Dev Task && isNull(s.assignee)) {
            passConditionValue = false;
        }
    }
}
setIssueEntityPropertyValue(key, "passCondition", passConditionValue);
//Jira Expression
JSON.stringify(issue.properties['passCondition']).includes('true')

Live Fields scripts

In Data Center, Live Fields is a just collection of functions within Power Scripts that are used to manipulate issue screens and the UI. In Jira Cloud, Live Fields was built as separate app for architectural reasons. This new Live Fields app does not use the SIL language, instead it uses JavaScript or TypeScript. When writing scripts for Live Fields for Jira Cloud an API written by Atlassian must be used. For this reason all Live Fields scripts will need to be converted from SIL to JavaScript.

For example:

//SIL (Data Center)
lfSet("summary", "Value to set");

//JavaScript (Cloud)
getFieldById("summary").setValue("Value to set");

Mail handler scripts

It is important to note that the incoming email service that is available in Power Scripts for Jira Cloud is different from Data Center in that it does not intercept emails coming in on the main “…@atlassian.net” email address. This is because it is currently not possible to intercept those emails as Atlassian has not made it possible to do so. In Jira Cloud, email scripts can only intercept emails going to a separate email account like a Gmail account for example.

It is due to this difference above that different functions were needed between Data Center and Cloud for incoming email scripts. These scripts will need to be modified to use the new functions.

 Data Center email handler script example
IncomingEmail mail = getIncomingEmail();
string issueKey = matchText(mail.subject, "[A-Z][A-Z]+-[0-9]+"); // find an issue key in the subject
if(isNull(issueKey)) {
	// if no issue key found, create a new issue
    string [] fields = {};
    fields += {"reporter", currentUserKey()};
    fields += {"assignee", getUserByEmail(mail.cc[0]).key}; 
    string newIssue = createIssue("TEST", "", "Task", mail.subject, "Minor", mail.body, {}, "", "", 0, fields);
    attachAllFilesFromEmail(newIssue);
    %newIssue%.watchers = getUserKeysFromEmails(mail.cc); 
} else {
	// if issue key found in subject, add a comment
    addComment(issueKey, currentUserKey(), mail.body);
}
 Cloud incoming email processing script example
IncomingEmail mail = getIncomingEmail();
string issueKey = mail.subject;
if(issueExists(issueKey)) {
    // add comment
    string commentText = mail.body;
    string userCommenting = getUserByEmail(mail.from).key;
    addComment(issueKey, userCommenting, commentText);
    attachAllFilesFromEmail(issueKey);
} else {
    // create issue
    string summary = mail.subject;
    string description = mail.body;
    string [] fields = {};
    fields += {"reporter", getUserByEmail(mail.from).key};
    createIssue("SCRUM", "", "Task", summary , "Minor", description, {}, "", "", fields);
}

Scripted JQL functions/keywords

With scripted JQL functions/keywords there is a large paradigm shift between Data Center and cloud that has to do with Jira directly and is not caused by Power Scripts.

  • In Data Center, scripted functions are executed when the search is executed. The SIL script performs its own, separate JQL search for each issue with the script determining if the issue should be included in the search results as each issue is evaluated one-by-one

  • In Cloud, scripted functions are executed in advanced of the search and the result of the script is stored with the issue. The JQL search uses these precalculated results to determine if the issue should be returned with the search results.

This will change the construction of the script JQL function/keyword in the following ways:

  • Scripts will not contain their own JQL search in the script

  • The return statement of the cloud scripts uses additional operations when compared to DC

  • JQL scripts in cloud can update the search values of parent and child issues as well as their own

For these reasons script JQL functions/keywords will need to be updated to use the new methods in cloud.

Script Migration Process/Strategy

The table below outlines the steps to perform automated script migration using a tool such as Jira Cloud Migration Assistant (JCMA) or Configuration Manager for Jira (CMJ).

Step 1: Migrate the Jira instance using a tool

  1. Update the sil.aliases properties file. For details, see SIL aliases.

  2. Search code for hard-coded custom field IDs.

  3. Convert hard-coded custom field IDs to aliases.

Step 2: Validate post function and Listener scripts

Starting with the post function and listener script types will quickly expose potential major issues. These scripts are more likely to contain project names, issue type names, and other configuration-specific elements that may need to be resolved. Early identification of discrepancies in these names lets you minimize the impact on the project and resolve potential issues that require Jira changes.

  1. In SIL Manager, run the syntax check on each script to validate the code.

  2. If you discover any name conflicts, use find/replace to search for similar issues across all scripts.

Step 3: Validate Scheduler scripts, Webhooks, SIL Panel, and SIL Runner Gadget scripts

Scripts of these types should migrate easily. Any major issues would have been caught and resolved earlier in the process.

  1. In SIL Manager, run the syntax check on each script to validate the code.

  2. If you discover any name conflicts, use find/replace to search for similar issues across all scripts.

Step 4: Convert Mail handler scripts

The changes required by mail handler scripts are minor and this conversion effort should be minimal.

For details, see the Mail handler scripts section.

Step 5: Convert JQL function scripts

Due to the nature of the changes, JQL scripts require more extensive updates than other script types during migration. SIL provides utility scripts that can help with JQL-related migration in two ways:

  • To scan your existing JQL filters and identify where DC keywords are used that won't work in Jira Cloud.

  • To automatically update those JQL filters to use the Cloud-compatible keywords.

For details, see the Scripted JQL functions/keywords section.

Step 6: Convert Live Fields scripts

Live Fields in Jira Cloud uses JavaScript and Atlassian APIs, unlike Data Center, which uses SIL. The cloud version of Live Fields has more limited functionality than the Data Center version. Converting these scripts requires significant work, including developing workarounds where Cloud features are missing.

For details, see the Live Fields section.

Useful scripts, tips and tricks

You can use some tools and methods to help convert, update, and clean up scripts when migrating from Jira DC to Jira Cloud, including workflow conversion, filter updates, and bulk script modifications.

Script conversion assistance with WorkFlow Pro

WorkFlow Pro is an AI chat agent run on Rovo that simplifies Jira automation processes. This application is currently being trained on the complete range of Apprifre workflow and automation apps, including the Simple Issue Language (SIL) used in Power Scripts. While Workflow Pro is new and its training is still ongoing, it can provide significant help for converting scripts after Jira DC to Cloud migration.


Scripts for cleaning up saved filters

You can use scripts to audit filters and update the syntax of specific functions used in saved filters.

 Script to identify filters that need updating based on function used

This analysis script helps assess the impact before making changes by identifying which filters need updating. It's a safe, read-only tool to use before running the actual update script.

for(JFilter f in admGetAllFilters()) {
    string oldFunction = "hasLinkType";
    
    if(contains(f.jql, oldFunction)) {
        runnerLog("Filter \"" + f.name + "\" [" + f.id + "] owned by " + userFullName(f.owner) + " <strong style=\"color:red;\">contains</strong> the function for removal: <strong>" + oldFunction + "</strong>", true);
    } else {
        runnerLog("Filter \"" + f.name + "\" [" + f.id + "] owned by " + userFullName(f.owner) + " <strong style=\"color:green;\">does not contain</strong> the function for removal: <strong>" + oldFunction + "</strong>", true);
    }
}
 Script to update the syntax of function used in saved filters

When migrating JQL queries from Jira DC to Cloud, use this template to convert function syntax from the issueFunction in format to the new equals operator format:

//Starting JQL format:
issueFunction in FUNCTION_NAME("PARAMETER") and ADDITIONAL_CONDITIONS

//Changes to:
FUNCTION_NAME = "PARAMETER" and ADDITIONAL_CONDITIONS

Where:

  • FUNCTION_NAME represents any JQL function name

  • PARAMETER represents the function's parameter

  • ADDITIONAL_CONDITIONS represents any additional JQL conditions

Example

This example shows how the transformation can work on a specific JQL query.

//starting JQL format
issueFunction in hasLinkType("Blockers") and resolution is empty

//would be changed to:
hasLinkType = "Blockers" and resolution is empty

This query is looking for:

  1. Issues that have a link of type Blockers.

  2. AND are unresolved (resolution is empty)

for(JFilter f in admGetAllFilters()) {
    string oldFunction = "hasLinkType";
    string newFunction = "hasLinkType";
    
    if(contains(f.jql, oldFunction)) {
        string jql = f.jql;    
        string [] pieces = split(f.jql, oldFunction);
        
        jql = replace(pieces[0], "issueFunction in ", "") + newFunction;
        
        pieces[1] = replace(pieces[1], "(", " = ");
        pieces[1] = replace(pieces[1], ")", "");
        
        jql += pieces[1];
        f.jql = jql;
        
        admUpdateFilter(f);
        runnerLog("Filter \"" + f.name + "\" [" + f.id + "] owned by " + userFullName(f.owner) + " has been updated to use the new syntax for function: <strong>" + oldFunction + "</strong>", true);
    }
}

For each filter containing the old hasLinkType syntax, the script:

  1. Splits the JQL at hasLinkType

  2. Removes issueFunction in from the first part

  3. Replaces parentheses with an equal sign (=)

  4. Reconstructs the JQL with the new syntax

  5. Updates the filter with the new JQL


How to make bulk changes on scripts

After migrating to Jira Cloud, scripts often require bulk changes. A common task is identifying scripts that use hard-coded custom field IDs (for example, customfield_). Here's how to search across all scripts for these references and perform the update:

  1. In the SIL Manager, right-click the silprograms folder, then click Download.

    This screenshot shows the expanded actions menu for the silprograms folder.

  2. Extract the downloaded zip file and open it in a tool such as VS Code.

  3. Use find and replace features to search and update all files in the selected folder.

    This screenshot shows the Find and Replace menus available from the Edit drop-down in VS Code.

  4. Compress (zip) the updated files.

  5. Go back to Power Scripts and navigate to the Self Help > Backup/Restore tab.

  6. Next, upload the zip file you saved.

    self-help-page-a.png

Uploading the zip file will replace ALL files in the silprograms folder.

Table of contents:

  • No labels