Missed Team ’24? Catch up on announcements here.

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

Modify/Edit server script to work in cloud script runner

Alok Kumar December 29, 2022

Hi,

We have created three scripted fields in Jira server which is working fine and we want to implement the same in Jira cloud however the same script does not work in cloud. Can someone help me modify the scripts ?

 

// Displays the sum of all story points for the Feature provided during Sprint planning.

import com.atlassian.jira.issue.CustomFieldManager;

import com.atlassian.jira.component.ComponentAccessor;

def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def cfManager = ComponentAccessor.getCustomFieldManager()

int totalSP = 0

int SP 

customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Sprint Estimate for Epic");

//log.debug("${customField.id}")

issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->

        log.debug("Link of type ${issueLink.issueLinkType.name} from ${issueLink.sourceObject} to ${issueLink.destinationObject}")

        log.debug("${issueLink.destinationObject.getCustomFieldValue(customField).toString()}")

    if(issueLink.issueLinkType.name.contains('Consists of')) {

        SP = issueLink.destinationObject.getCustomFieldValue(customField) ?: 0

        totalSP += SP;

    }

   } 

return totalSP;

------------------------------------------------------------------------------------------------

import com.atlassian.jira.issue.CustomFieldManager;

import com.atlassian.jira.component.ComponentAccessor;

 

def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def cfManager = ComponentAccessor.getCustomFieldManager()

//def log = Logger.getLogger("com.onresolve.jira.groovy")

//log.setLevel(Level.INFO)

double totalSP = 0

customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Completed Story Points");

//log.debug("${customField.id}")

issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->

//        log.debug("Link of type ${issueLink.issueLinkType.name} from ${issueLink.sourceObject} to ${issueLink.destinationObject}")

//        log.debug("${issueLink.destinationObject.getCustomFieldValue(customField).toString()}")

    if(issueLink.issueLinkType.name.contains('Consists of')) {   

              def SP = issueLink.destinationObject.getCustomFieldValue(customField) ?: 0

        totalSP += SP

        }

  }

//log.info("Closed ${j} of ${i}");  

return totalSP

---------------------------------------------------------------------------------------------

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 29, 2022

Jira Cloud and Server are two very different applications, and hence, so is Scriptrunner on the two platforms.

You can't "convert" a script, or even most of the settings from one to the other, you will have to re-implement what you are doing in the way the new platform needs to do it.

Start with a read through https://docs.adaptavist.com/sr4js/latest/scriptrunner-migration/migrating-to-or-from-cloud/migrate-from-scriptrunner-for-jira-server-to-cloud

TAGS
AUG Leaders

Atlassian Community Events