Custom Field Context in CMJ

 

Problem

When a custom field context is already present in the target instance and is associated to a project and if we deploy a snapshot containing the same context field with the same project associated to it, then during migration, CMJ creates a new context again instead of mapping it to the old context in the target instance.

Solution

If you are trying to deploy the same project in the target, and the custom field context is already available on the this instance, CMJ does not give the option to add a new context for the same project. This is because Jira does not allow to have two contexts for the same project.

CMJ matches custom field contexts by the projects they are associated with. It means that if we have the same context in projects in the snapshot and in the target instance, i.e., in the snapshot project A has "XYZ" context and in the target instance project A has "XYZ" context and no other projects are associated with the "XYZ" context in the target instance then the new context will not be created and "EDIT FIELD CONTEXTS" option is disabled as shown in the below screenshot.

 

 

CMJ creates new context in the below scenario:

If we have same context in projects in the snapshot and in target instance i.e in snapshot project A has "XYZ" context and in target instance "XYZ" context has projects A and C associated with the context. Here project C is also associated in target instance along with project A, but in the snapshot which we are going to deploy, it has only "XYZ" context associated with project A, then the new context will be created even though same context is there in target instance. This is because Context "XYZ" in the snapshot is associated only with Project A as the snapshot is only for project A. That is the reason why in this case a new context is created. "The name of the context is not taken into account in this case but the project is considered in deciding the duplicity." If there is any reference of another project in the snapshot but that project is not present in the snapshot which we have created then also new context will be created. Reference means linked issues, etc. between any two projects when we are creating snapshot. In the UI we may not know or it will not show that reference, but in the background it may have the reference and in the analyse phase CMJ will analyse between the project in snapshot and the project in target instance. If there is any difference then the new context will be created.

In the below screenshots, we have a snapshot that contains Hobbies custom field which is already present in the target instance. But when we try to deploy the snapshot it tries to create a new context by default. This is because in the source snapshot the custom field context is already associated with multiple projects. This can be identified by checking the project XML configuration.

 

 

 

To know whether the project configuration is same or not, convert the source snapshot zip file to XML by going to CMJ advanced settings as shown in the below screenshot and upload the snapshot or load the snapshot from the current instance and then select "Convert" and then download the converted XML file. 

 

 

Unzip the downloaded file and open the configuration XML file of the snapshot file. Syntax of the file name will be snapshotname.configuration.xml. For reference you can check in the below screenshot here "XYZSNAP" is the snapshot file name

Open the configuration.xml file and search with the keyword "projectKeys". Then in the resultant project keys filter, the projects that are mentioned should match the context configuration projects in the target instance. Then only new context fields are not created.

From the below screenshot you can see multiple projects are associated in source snapshot, so CMJ is creating a new context again.Â