2
1
0

Hi, I found a script example for issuelinktype mapping in this community for Jira cloud. I want to map specific issuelinktypes from service desk to default Jira software issuelinktypes.


This is my incoming script:


def issueLinkTypeMapping = [
  // replace the mapping below accordingly     "Remote side" : "Local side"
   "Blocks" : "Relates"
]
issue.issueLinks = replica.issueLinks.collect { issueLink ->
    issueLink.linkTypeName = (issueLinkTypeMapping[issueLink.linkTypeName])? issueLinkTypeMapping[issueLink.linkTypeName] : issueLink.linkTypeName
}


Unfortunately, I get an exception:


class java.lang.String cannot be cast to class com.exalate.basic.domain.hubobject.v1.BasicHubIssueLink (java.lang.String is in module java.base of loader 'bootstrap'; com.exalate.basic.domain.hubobject.v1.BasicHubIssueLink is in unnamed module of loader 'app')


Any ideas?


Best, Jasmin


    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi Jasmin,


      Let me try this question.


      I guess the root cause is you are returning a list of issuelink type names instead of modifying the issuelink type names

      import groovy.json.JsonSlurper;
      
      def jsonSlurper = new JsonSlurper();
      def originalList = jsonSlurper.parseText('[{"app":"Gauge Gadgets", "platform":"jira"}, {"app":"Out of Office", "platform": "jira"}]');
      log.warn("---- original List ------")
      log.warn(originalList);
      //[{app=Gauge Gadgets, platform=jira}, {app=Out of Office, platform=jira}]
      
      
      
      def partialList = [];
      partialList = originalList.collect {element -> element.platform = 'Jira'};
      log.warn(partialList);    
      //This will return 
      //[Jira, Jira]
      
      def fullList = [];
      fullList = originalList.collect { Map<String, Object> element -> 
          return [
              "app": element.app as String,
              "platform": "Jira" as String
              ]
      };
      log.warn(fullList)
      //this method will return this
      //[{app=Gauge Gadgets, platform=Jira}, {app=Out of Office, platform=Jira}]

      You probably need to return something like this (and modify linkTypeName)

      replica.issueLinks.collect { jLink ->
      return [
                                  "id" : jLink.id as String,
                                  "linkTypeName" : jLink.issueLinkType.name as String,
                                  "otherIssueId" : otherIssueId as String,
                                  "otherIssueKey" : otherIssue.key,
                                  "isOutward" : isOutward,
                                  "linkTypeStyle" : jLink.issueLinkType.style
      ]}
        CommentAdd your comment...