Components field is one of the standard fields of an issue. You can synchronize them as any other issue field.

This article provides description and scripts that help to synchronize issue components and create new component if it does not exist on the destination side.

Component issue field reference.

Source instance

Add the issue components to your Data Filter to send them to the destination side:

replica.components = issue.components

Destination instance 

Exalate uses CreateComponent nodeHelper to create a new component and add it to the Components field.

Add the code below into the incoming sync(create processor) to create components on your side. To update components use the same code in the Incoming sync(change processor).

Jira Server

If you sync components with Jira Cloud there're several ways to create components, depending on the information you know about the remote side. 

  •  map the remote component lead accountId to the local component lead email

    final def userMapping = [
          “557358:bda57a72g56a9-4219-9c29-7d666481388f” :  “admin@admin.com” 
    // where "557358:bda57a72g56a9-4219-9c29-7d666481388f" is the accountId of the Jira Cloud user who is the component lead
    ]
    
    issue.components = replica.components.collect { component ->
    def remoteComponentLeadKey = component.lead?.accountId
    def localComponentLeadName = userMapping[remoteComponentLeadKey]
    nodeHelper.createComponent(
    	issue, 
    	component.name, 
    	component.description, 
    	localComponentLeadName, 
    	component.assigneeType?.name()
    	)
    }

  • set default component lead if the remote component lead email is not found

    def defaultUser = nodeHelper.getUserByEmail(“default user email”)
    issue.components = replica.components.collect { component ->
    def remoteComponentLeadEmail = component.lead?.email
    def localComponentLeadName = nodeHelper.getUserByEmail(remoteComponentLeadEmail)?.username
    nodeHelper.createComponent(
    	issue, 
    	component.name, 
    	component.description, 
    	localComponentLeadName ?: defaultUser.username, 
    	component.assigneeType?.name()
    	)
    }


If you sync components between Jira Server instances add the code below into the Incoming sync(create/change processor)

issue.components = replica.components.collect{
	nodeHelper.createComponent(
		issue, 
		it.name, 
		it.description, 
		it.leadKey, 
		it.assigneeType.name()
		)
	}
...

Jira Cloud

  • If you want to sync the components with Jira Server, you need to map the remote component lead email to the local component lead accountId.

    Incoming sync (create/change processor)

    final def userMapping = [
           “admin@admin.com” : “557358:bda57a72g56a9-4219-9c29-7d666481388f”, 
    // where "557358:bda57a72g56a9-4219-9c29-7d666481388f" is the accountId of the Jira Cloud user who is the component lead
    ]
    issue.components = replica.components.collect { component ->
    def remoteComponentLeadEmail = component.lead?.email
    def localComponentLeadKey = userMapping[remoteComponentLeadEmail]
    nodeHelper.createComponent(
    	issue, 
    	component.name, 
    	component.description, 
    	localComponentKey, 
    	component.assigneeType?.name()
    	)
    }

  • If you sync between Jira Cloud instances use the code below

    The user with the specified accountId must be a user on your instance.

    issue.components = replica.components.collect { 
    	component ->
    	nodeHelper.createComponent(
    		issue, 
    		component.name, 
    		component.description, 
    		component.leadKey, 
    		component.assigneeType?.name()
    	)
    }