Scilife: jira - zendesk

outgoing zendesk
replica.key            = issue.key
replica.summary        = issue.summary
replica.description    = issue.description
replica.attachments    = issue.attachments
replica.comments       = issue.comments

replica.status         = issue.status
replica.priority       = issue.priority
replica.Requester      = issue.Requester
replica.reporter       = issue.reporter
replica.organization   = issue.organization_id
replica.creator        = issue.creator
replica.assignee       = issue.assignee
outgoing sync jira
replica.key            = issue.key
replica.type           = issue.type
replica.assignee       = issue.assignee
replica.reporter       = issue.reporter
replica.summary        = issue.summary
replica.description    = issue.description
replica.labels         = issue.labels

replica.comments = issue.comments.findAll { comment ->
    comment.body.startsWith("#") 
}



replica.resolution     = issue.resolution
replica.status         = issue.status
replica.parentId       = issue.parentId
replica.priority       = issue.priority
replica.attachments    = issue.attachments
replica.project        = issue.project
replica.fixVersions = issue.fixVersions


//Comment these lines out if you are interested in sending the full list of versions and components of the source project. 
replica.project.versions = []
replica.project.components = []
incoming sync jira
if(firstSync){
   issue.projectKey   = "SL" 
   // Set type name from source issue, if not found set a default
   issue.typeName     = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Incident"
     syncHelper.syncBackAfterProcessing()
issue.summary      = replica.summary
issue.description  = replica.description
}

issue.comments     = commentHelper.mergeComments(issue, replica)
issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)
issue.labels += nodeHelper.getLabel("exalated")



def priorityMapping = [
        // remote side priority <-> local side priority             
          "urgent" : "Highest",
          "high" : "High",
          "normal" : "Medium",
          "low":"Low"
    ]
def priorityName = priorityMapping[replica.priority?.name] ?: "Low" 
issue.priority = nodeHelper.getPriority(priorityName)


def componentMapping = [
        "core_" : "Core",
        "document_control_" : "Document Control",
        "trainings" : "Trainings",
        "supplier_management" : "Supplier Management",
        "risk_assessment" : "Risk Assessments",
        "record_management_" : "Record Management",
        "qpd" : "Quality Process Designer",
        "p_r" : "Print & Reconciliation",
        "kpi" : "KPI",
        "events" : "Events",
        "equipment" : "Equipment",
        "design__development" : "Design & Development",
        "competences" : "Competences",
        "change_control" : "Change Control",
        "audits" : "Audits",
        "academy" : "Academy",
        "active_directory" : "Active Directory",
        "novartis-cirf" : "CIRF",
        "integrations" : "Integrations",
    
    ]

def component = nodeHelper.getComponent(componentMapping[replica.customFields."About".value.value], nodeHelper.getProject(issue.projectKey))

issue.components += component

issue?."ZD status" = replica.status.name
incoming zendesk
issue.labels += nodeHelper.getLabel("exalated")

issue."Jira Task" = replica.key

//issue.summary      = replica.summary
issue.description  = replica.description ?: "No description"
issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)
issue."Jira Ticket Number" = replica.key

if (replica?.fixVersions[0]?.name) {
    issue.setStatus("open")
}




def mapping = [
    "[~accountid:5ea020dc9cc9330c111e8008]": "Trine Michelsen",
    "[~accountid:6245fbbaad6b7e006aa56dc6]": "Catherine Kolar",
    "[~accountid:631221dc3310c2492b5aa0a3]": "Fabiola Samueli",
    "[~accountid:712020:9502b25d-4516-4465-ac11-fb53bb2bd22f]": "Samuel Auler",
    "[~accountid:63eb711ceaf0b28dfd1ae987]": "Andrea Joppich",
    "[~accountid:63f74e9d3ec8aa51d3d31698]": "Gemma Boldison"
]

replica.addedComments.each { comment ->
    mapping.each { key, value ->
        comment.body = comment.body.replace(key, value)
    }
}


issue.comments = commentHelper.mergeComments(issue, replica, { it.internal = true; it })


if(replica.comments.size() != previous.comments.size()){
    issue.setStatus("open")
}

//Receive a Custom Field value
//issue.customFields."CF Name".value = replica.customFields."CF Name".value
/*
Status Synchronization

Sync status according to the mapping [remote issue status: local issue status]
If statuses are the same on both sides don"t include them in the mapping
def statusMapping = ["Open":"New", "To Do":"Open"]
def remoteStatusName = replica.status.name
issue.setStatus(statusMapping[remoteStatusName] ?: remoteStatusName)
*/