RTC Java Client Library
I am trying to access RTC from my java application. The api documents are really not good enough to develop a proper code and there is no javadoc either. So I really need help out here to go further.
I managed to connect RTC and get some basic information about a work item but what I need is a bit more than that. I need the information that we can access with RTC UI on build request page, like Deployment description, References ext. Could some one please help me how I can get that information.
3 answers
If you are not already refereed the below link, I would request you to refer.
https://rsjazz.wordpress.com/2013/03/14/what-apis-are-available-for-rtc-and-what-can-you-extend/
https://jazz.net/library/article/1229
http://thescmlounge.blogspot.in/
Note: Refer discussion also from the links.
Regards,
Arun.
Comments
Hi Arun,
I am using the below method and getting a null pointer exception when I try to get itemId from build definition, although my work item id is correct.
public static void getBuildRequest(ITeamRepository repo) throws TeamRepositoryException {
ITeamBuildClient buildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class);
/ The build definition is easy to get once you know the build ID /
IBuildDefinition definition = buildClient.getBuildDefinition("313491", null);
System.out.println("definition.getItemId(): "+ definition.getItemId());
IBuildResultQueryModel buildResultQueryModel = IBuildResultQueryModel.ROOT;
IItemQuery query = IItemQuery.FACTORY.newInstance(buildResultQueryModel);
/ Build up a query filter predicate that accepts a build definition as input to the query and checks for
any non-personal builds that have a completed state. /
IPredicate predicate = (buildResultQueryModel.buildDefinition()._eq(query.newItemHandleArg()))._and(
buildResultQueryModel.personalBuild()._isFalse())._and(
buildResultQueryModel.buildState()._eq(BuildState.COMPLETED.name()));
query.filter(predicate);
/ Order by build start time in descending order /
query.orderByDsc(buildResultQueryModel.buildStartTime());
/ Query for items using the build definition's item ID as the argument. /
/ Use a smaller page size if possible depending on what is queried. /
IItemQueryPage queryPage = buildClient.queryItems(query, new Object[] { definition.getItemId() },
IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, null);
/ Iterate through the results of this page /
while (queryPage.hasNext()) {
queryPage = (IItemQueryPage) buildClient.fetchPage(queryPage.getToken(), queryPage.getNextStartPosition(), 1, null);
/ Iterate through each subsequent page. Break out of the loop if finished early. /
}
}
and here is the code that let me connect to repo
String repoUri = "https://xxxxx.eu.int:9443/jazz/";
TeamPlatform.startup();
try {
// Login to the repository using the provided credentials
if(TeamPlatform.getTeamRepositoryService() != null) {
ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(repoUri);
repo.registerLoginHandler(new ILoginHandler2() {
@Override
public ILoginInfo2 challenge(ITeamRepository repo) {
String userId = "jhhjkll3"; // Retrieve the userId in a secure way
String password = "kkk"; // Retrieve the password in a secure way
return new UsernameAndPasswordLoginInfo(userId, password);
}
});
repo.login(null);
getBuildRequest(repo);
Finally, the com.ibm.team.build.client.ITeamBuildClient.getBuildDefinition(String, IProgressMonitor) wants the Build Definition ID and not the build ID.
/**
* Retrieves the build definition with the given id.
*
* @param buildDefinitionId
* The build definition to retrieve.
* @param progressMonitor
* The progress monitor to track progress on or <code>null</code>
* if progress monitoring is not desired.
* @return The build definition, or <code>null</code> if no build
* definition with the given id is found.
* @throws IllegalArgumentException
* If the <code>buildDefinitionId</code> is <code>null</code>.
* @throws TeamRepositoryException
* If an error occurs while accessing the repository.
*/
public IBuildDefinition getBuildDefinition(String buildDefinitionId, IProgressMonitor progressMonitor)
throws TeamRepositoryException, IllegalArgumentException;
Thanks for your response, unfortunately I am still struggling to get the information that I need with RTC library. Here is what I really need to get. Could you please help me how can I get that information by using RTC java API. In RTC, we have a custom part in work item which we called Build/Deployment, you can see how it looks like from the screenshot below. Could you please tell me by using which classes I can get the data inside that part?
Thanks & REgards
Evrim