Can I use RTC CLI to associate a change set to a workitem in another repository?

6 answers

Yes, depending on which version of the scm cli client it should be either 'scm changeset associate <changeset uuid/alias> <workitem>@<repoNickname_or_repoUrl>' or 'scm add workitem <changeset uuid/alias> <workitem>@<repoNickname_or_repoUrl>'
I believe you should login into the repository using the scm cli prior to issuing that command.

Thanks Shashikant for your help. But I encountered another issue when using this syntax.
For example, I have 2 repositories, repA is the SCM repository and repB stores the workitems. I was using 'scm add workitem <changesetUUID>@repA <workitemID>@repB', my RTC client is 4.0.6. Then there reports the following error:
'Problem running 'add workitem':
Service failed to communicate with repository repA: CRJAZ0105E The request for the following URL was denied: /ccm/service/com.ibm.team.scm.common.IScmService. The status is "Unauthorized".'
I have logged into both repositories before the add workitem command. I also have tried to support login info in the add workitem command (-u <userid> -P <password>), but it didn't work either. Anything I missed here? Thank you!
For example, I have 2 repositories, repA is the SCM repository and repB stores the workitems. I was using 'scm add workitem <changesetUUID>@repA <workitemID>@repB', my RTC client is 4.0.6. Then there reports the following error:
'Problem running 'add workitem':
Service failed to communicate with repository repA: CRJAZ0105E The request for the following URL was denied: /ccm/service/com.ibm.team.scm.common.IScmService. The status is "Unauthorized".'
I have logged into both repositories before the add workitem command. I also have tried to support login info in the add workitem command (-u <userid> -P <password>), but it didn't work either. Anything I missed here? Thank you!
Comments

It is taking the repository name as 'repA' which seems incorrect. When you logged in using the cli did you specify a nick name?
For ex: scm login -r https://your_repo_url -u user_name -P password -n nick_name
If so, can you run 'scm list credentials' and see if the nickname is listed against the repo url.

Oh, 'repA' and 'repB' was confusing.. To make things clear, I just used 'repA' and 'repB' here to represent the repo url so it's shorter. In my real case, I used the full repo url after @, but it didn't work and reported error

There is no error/exception if I execute 'scm list changesets', but it always reports 'No change sets found for the specified workitems' (As I suggested early, the workitems and the changesets are in different repositories, I'm not sure if this result is as expected?)
I also found that when executing 'scm add workitem', it occasionally throws exceptions like:
java.lang.NullPointerException
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.getBundle(RegistryStrategyOSGI.java:150)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:166)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:904)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry$Descriptor$1.run(ClientLibraryFactoryRegistry.java:140)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry$Descriptor.getFactory(ClientLibraryFactoryRegistry.java:132)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry.getClientLibrary(ClientLibraryFactoryRegistry.java:89)
at com.ibm.team.repository.client.internal.TeamRepository.getClientLibrary(TeamRepository.java:527)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.getPreviewManager(ResourceReferenceResolver.java:199)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolveWithResourcePreview(ResourceReferenceResolver.java:271)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolveWithRepositoryItems(ResourceReferenceResolver.java:258)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolve(ResourceReferenceResolver.java:162)
at com.ibm.team.filesystem.client.internal.calm.OslcLinkUtil.fetchDetails(OslcLinkUtil.java:358)
at com.ibm.team.filesystem.rcp.core.internal.oslc.OslcLinkWrapper.fetchDetails(OslcLinkWrapper.java:299)
at com.ibm.team.filesystem.rcp.core.internal.changes.util.listeners.UpdateChangesJob.run(UpdateChangesJob.java:482)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
java.lang.NullPointerException
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.getBundle(RegistryStrategyOSGI.java:150)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:166)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:904)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry$Descriptor$1.run(ClientLibraryFactoryRegistry.java:140)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry$Descriptor.getFactory(ClientLibraryFactoryRegistry.java:132)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry.getClientLibrary(ClientLibraryFactoryRegistry.java:89)
at com.ibm.team.repository.client.internal.TeamRepository.getClientLibrary(TeamRepository.java:527)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.getPreviewManager(ResourceReferenceResolver.java:199)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolveWithResourcePreview(ResourceReferenceResolver.java:271)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolveWithRepositoryItems(ResourceReferenceResolver.java:258)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolve(ResourceReferenceResolver.java:162)
at com.ibm.team.filesystem.client.internal.calm.OslcLinkUtil.fetchDetails(OslcLinkUtil.java:358)
at com.ibm.team.filesystem.rcp.core.internal.oslc.OslcLinkWrapper.fetchDetails(OslcLinkWrapper.java:299)
at com.ibm.team.filesystem.rcp.core.internal.changes.util.listeners.UpdateChangesJob.run(UpdateChangesJob.java:482)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Problem running 'add workitem':
Service failed to communicate with repository https://xxxxxx:9443/ccm/: CRJAZ0105E The request for the following URL was denied: /ccm/service/com.ibm.team.scm.common.IScmService. The status is "Unauthorized".
I also found that when executing 'scm add workitem', it occasionally throws exceptions like:
java.lang.NullPointerException
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.getBundle(RegistryStrategyOSGI.java:150)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:166)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:904)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry$Descriptor$1.run(ClientLibraryFactoryRegistry.java:140)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry$Descriptor.getFactory(ClientLibraryFactoryRegistry.java:132)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry.getClientLibrary(ClientLibraryFactoryRegistry.java:89)
at com.ibm.team.repository.client.internal.TeamRepository.getClientLibrary(TeamRepository.java:527)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.getPreviewManager(ResourceReferenceResolver.java:199)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolveWithResourcePreview(ResourceReferenceResolver.java:271)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolveWithRepositoryItems(ResourceReferenceResolver.java:258)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolve(ResourceReferenceResolver.java:162)
at com.ibm.team.filesystem.client.internal.calm.OslcLinkUtil.fetchDetails(OslcLinkUtil.java:358)
at com.ibm.team.filesystem.rcp.core.internal.oslc.OslcLinkWrapper.fetchDetails(OslcLinkWrapper.java:299)
at com.ibm.team.filesystem.rcp.core.internal.changes.util.listeners.UpdateChangesJob.run(UpdateChangesJob.java:482)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
java.lang.NullPointerException
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.getBundle(RegistryStrategyOSGI.java:150)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:166)
at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:904)
at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry$Descriptor$1.run(ClientLibraryFactoryRegistry.java:140)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry$Descriptor.getFactory(ClientLibraryFactoryRegistry.java:132)
at com.ibm.team.repository.client.internal.ClientLibraryFactoryRegistry.getClientLibrary(ClientLibraryFactoryRegistry.java:89)
at com.ibm.team.repository.client.internal.TeamRepository.getClientLibrary(TeamRepository.java:527)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.getPreviewManager(ResourceReferenceResolver.java:199)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolveWithResourcePreview(ResourceReferenceResolver.java:271)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolveWithRepositoryItems(ResourceReferenceResolver.java:258)
at com.ibm.team.calm.foundation.client.preview.ResourceReferenceResolver.resolve(ResourceReferenceResolver.java:162)
at com.ibm.team.filesystem.client.internal.calm.OslcLinkUtil.fetchDetails(OslcLinkUtil.java:358)
at com.ibm.team.filesystem.rcp.core.internal.oslc.OslcLinkWrapper.fetchDetails(OslcLinkWrapper.java:299)
at com.ibm.team.filesystem.rcp.core.internal.changes.util.listeners.UpdateChangesJob.run(UpdateChangesJob.java:482)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Problem running 'add workitem':
Service failed to communicate with repository https://xxxxxx:9443/ccm/: CRJAZ0105E The request for the following URL was denied: /ccm/service/com.ibm.team.scm.common.IScmService. The status is "Unauthorized".