1
0
-1

Hi,

I try to set a default epic when I synch two issue between Jira Service Management and Jira Software.

I find this documentation on your site:

https://docs.idalko.com/exalate/display/ED/How+to+set+a+default+epic+on+the+destination+side+in+Jira+on-premise

When I insert the script and try to synch with the default epic, I got this error: No such property: issues for class: com.atlassian.jira.issue.search.SearchResults



Script:



/**
 Usage:

 Add the snippet below to the end of your "Incoming sync ... (create processor / change processor)":

DefaultEpic.setEpic(issue, "Service")

 * */
class DefaultEpic {
    static getEpic(String epicName) {
        def sserv = com.atlassian.jira.component.ComponentAccessor.getComponent(com.atlassian.jira.bc.issue.search.SearchService.class)
        def nserv = com.atlassian.jira.component.ComponentAccessor.getOSGiComponentInstanceOfType(com.exalate.api.node.INodeService.class)

        def proxyAppUser = nserv.proxyUser
        def parseQuery = { com.atlassian.jira.user.ApplicationUser u, String qStr ->
            try

{                 // Jira 7 way                 return sserv.parseQuery(u, qStr)             }

catch (MissingMethodException ignore)

{                 // Jira 6 way                 return sserv.parseQuery(u.getDirectoryUser(), qStr)             }


        }
        def searchOverrideSecurity = { com.atlassian.jira.user.ApplicationUser u, finalQuery ->
            try

{                 // Jira 7 way                 return sserv.searchOverrideSecurity(u, finalQuery, com.atlassian.jira.web.bean.PagerFilter.getUnlimitedFilter())             }

catch (MissingMethodException ignore)

{                 // Jira 6 way:     //    SearchResults search(User var1, Query var2, PagerFilter var3) throws SearchException;                 //noinspection GroovyAssignabilityCheck                 return sserv.search(u.getDirectoryUser(), finalQuery, com.atlassian.jira.web.bean.PagerFilter.getUnlimitedFilter())             }


        }
        def search = { String jql ->
            //get board query
            def queryRes = parseQuery(proxyAppUser, jql)
            if (!queryRes.valid) {
                throw new com.exalate.api.exception.IssueTrackerException("Failed to parse JQL `$jql`: `${queryRes.errors.errorMessages}`. Please review the script.".toString())
            }
            def query = queryRes.query

            // find issues on board
            def sRes = searchOverrideSecurity(proxyAppUser, query)
            def issues = sRes.issues => ERROR HERE
            def issuekeys = issues.collect

{ [                     "id" : it.id,                     "key": it.key,             ] as Map<String, Object>; }


            issuekeys
        }

        def im = com.atlassian.jira.component.ComponentAccessor.issueManager
        def cfm = com.atlassian.jira.component.ComponentAccessor.customFieldManager
        def cf = cfm
                .getCustomFieldObjects()//.getCustomFieldObjectsByName("Epic Name")
                .find

{ cf -> cf.customFieldType.key == "com.pyxis.greenhopper.jira:gh-epic-label" }


        def epicIssueKey = search("\"${(cf.clauseNames.jqlFieldNames as List<String>).find()}\" = \"${epicName}\"".toString()).find()
        if (epicIssueKey == null)

{             return null         }


        im.getIssueObject(epicIssueKey.id as Long)
    }

    static setEpic(com.exalate.basic.domain.hubobject.v1.BasicHubIssue issue, String epicName)

{         issue.customFields."Epic Link".value = getEpic(epicName)     }


}
    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      There have been a change since Jira 8.5.1.

      In your script you have to change the line as written in italic and bold.


      class DefaultEpic {
          static getEpic(String epicName) {
              //def sserv = com.atlassian.jira.component.ComponentAccessor.getComponent(com.atlassian.jira.bc.issue.search.SearchService.class)
              def sserv = com.atlassian.jira.component.ComponentAccessor.getComponent(com.atlassian.jira.bc.issue.search.SearchService.class)
              def nserv = com.atlassian.jira.component.ComponentAccessor.getOSGiComponentInstanceOfType(com.exalate.api.node.INodeService.class)

              def proxyAppUser = nserv.proxyUser
              def parseQuery = { com.atlassian.jira.user.ApplicationUser u, String qStr ->
                  try

      {                 // Jira 7 way                 return sserv.parseQuery(u, qStr)             }

      catch (MissingMethodException ignore)

      {                 // Jira 6 way                 return sserv.parseQuery(u.getDirectoryUser(), qStr)             }


              }
              def searchOverrideSecurity = { com.atlassian.jira.user.ApplicationUser u, finalQuery ->
                  try

      {                 // Jira 8 way                 return sserv.searchOverrideSecurity(u, finalQuery, com.atlassian.jira.web.bean.PagerFilter.getUnlimitedFilter())             }

      catch (MissingMethodException ignore)

      {                 // Jira 6 way:     //    SearchResults search(User var1, Query var2, PagerFilter var3) throws SearchException;                 //noinspection GroovyAssignabilityCheck                 return sserv.search(u.getDirectoryUser(), finalQuery, com.atlassian.jira.web.bean.PagerFilter.getUnlimitedFilter())             }


              }
              def search = { String jql ->
                  //get board query
                  def queryRes = parseQuery(proxyAppUser, jql)
                  if (!queryRes.valid) {
                      throw new com.exalate.api.exception.IssueTrackerException("Failed to parse JQL `$jql`: `${queryRes.errors.errorMessages}`. Please review the script.".toString())
                  }
                  def query = queryRes.query

                  // find issues on board
                  def sRes = searchOverrideSecurity(proxyAppUser, query)
                  def issues = sRes.issues => ERROR
                  def issues = sRes.results => SOLUTION
                  def issuekeys = issues.collect

      { [                     "id" : it.id,                     "key": it.key,             ] as Map<String, Object>; }


                  issuekeys
              }

              def im = com.atlassian.jira.component.ComponentAccessor.issueManager
              def cfm = com.atlassian.jira.component.ComponentAccessor.customFieldManager
              def cf = cfm
                      .getCustomFieldObjects()//.getCustomFieldObjectsByName("Epic Name")
                      .find

      { cf -> cf.customFieldType.key == "com.pyxis.greenhopper.jira:gh-epic-label" }


              def epicIssueKey = search("\"${(cf.clauseNames.jqlFieldNames as List<String>).find()}\" = \"${epicName}\"".toString()).find()
              if (epicIssueKey == null)

      {             return null         }


              im.getIssueObject(epicIssueKey.id as Long)
          }

          static setEpic(com.exalate.basic.domain.hubobject.v1.BasicHubIssue issue, String epicName)

      {         issue.customFields."Epic Link".value = getEpic(epicName)     }


      }



      (The following was raised as a ticket and the client answered it there). 

        CommentAdd your comment...