Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

RTC Java Client Library

Hi,
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.

0 votes



3 answers

Permanent link
Hi Evrim,

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.

0 votes

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);


Permanent link
Follow https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/ and properly set up your environment for debugging. Note the SDK comes with comments. https://rsjazz.wordpress.com/2015/10/28/build-artifacts-publishing-and-automated-build-output-management-using-the-plain-java-client-libraries/ shows some built API.

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;

0 votes


Permanent link
Hi Arun,
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


0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 11,074

Question asked: May 20 '16, 10:07 a.m.

Question was seen: 4,647 times

Last updated: May 24 '16, 8:23 a.m.

Confirmation Cancel Confirm