It's all about the answers!

Ask a question

Could not save the copied build engine using RTC java api


Richar Cai (171816) | asked May 31 '16, 8:26 p.m.
edited Jun 17 '16, 1:23 p.m. by David Lafreniere (4.7k7)
Dear Team,

I am trying to create a build engine in RTC by using java api. I use the method ".copyEngine()", but the new build engine is failed to save. The error message mentions that the item which I am trying to save could not be found from RTC database. 
Could you give me some advice?  
Thank you very much!

My code is simple as below:  

===================================

String originalBuildId = "CI_BF_Agent_NO.2";

IBuildEngine originalBuildEngine = (IBuildEngine) cbe.getBuildEngine(originalBuildId).getWorkingCopy();

//IBuildEngine newEngine = BuildItemFactory.createBuildEngine();

IBuildEngine  newEngine = originalBuildEngine.copyEngine(); 

newEngine.setId("R_CI_BF_Agent_NO.2");

newEngine.setActive(true);

newEngine.setProcessArea(originalBuildEngine.getProcessArea());

buildClient.save(newEngine, null);  

===========================



Comments
Ralph Schoon commented Jun 01 '16, 3:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I basically don't know. But you an search the RTC SDK for IBuildEngine, find the interface, and search for IBuildEngine.copyEngine() and look at what they are doing. If you run an Eclipse Debug client, you can actually step through the build engine creation wizard, which also uses the copyEngine() method.


Richar Cai commented Jun 04 '16, 3:51 a.m.

 Dear Ralph,

Thank you very much for your information. I will try it later.


2 answers



permanent link
sam detweiler (12.5k6185201) | answered Jun 04 '16, 8:09 a.m.
edited Jun 04 '16, 8:15 a.m.
in my copy project utility, I was never able to make copyEngine() work either.. I gave up and wrote my own copy functions..

now, in MOST cases, I was trying to copy across systems, so the copyEngine() function wouldn't have worked anyhow.

permanent link
Arne Bister (2.6k12732) | answered Jun 03 '16, 9:09 a.m.
JAZZ DEVELOPER
Richar,

please check
https://jazz.net/forum/questions/151314/how-to-edit-jenkins-url-on-build-engine-using-java-api

also all the comments. I believe the key might be to fetch the complete refreshed engine before copying:

buildEngine = (IBuildEngine) getTeamRepository().itemManager()
                .fetchCompleteItem(buildEngine, IItemManager.REFRESH, null);

If this helps please mark the answer as accepted,

- Arne


Comments
Richar Cai commented Jun 04 '16, 4:29 a.m.

 Dear Arne,

I tried the "fetchCompleteItem" method, but it still failed and reported the same error.
The error message is as below:
[main] INFO  [com.cbm.commons.SysoutProgressMonitor] - ConnectedException in thread "main" com.ibm.team.repository.common.ItemNotFoundException: CRJAZ0215E Could not find the item blew from database:com.ibm.team.build.internal.common.model.impl.BuildEngineHandleImpl@5e0206a (stateId: <unset>, itemId: [UUID _e2tr8Cn2EeaDBeT3ten9bw], origin: null, immutable: <unset>)  at com.ibm.team.repository.service.internal.RepositoryItemService.doFetchItem(RepositoryItemService.java:544)

Your answer


Register or to post your answer.