It's all about the answers!

Ask a question

How to get all the build definitions under a project area?


Yung-Hsiang Chan (34913) | asked Oct 06 '14, 11:21 p.m.
edited Oct 07 '14, 12:12 a.m. by Geoffrey Clemm (30.1k33035)
Hi, I'm a new user for RTC Client API.
I want to retrieve all the buildresults under a specific project area.
(Like on Eclipse GUI, I can see all the buildresults which belong to a specific project area.)

The interface ITeamBuildClient  has two related functions: getBuildDefinition and getBuildResultContributions.
The former needs builddefition name and the latter needs IBuildResultHandle. 

I've read BuildJavaProgrammingExamples which querying buildresult with tags.

So now I still don't know how to get all the builddefinitons without any tags or ids.

Could anyone help for this problem?

Thank you very much!

Accepted answer


permanent link
sam detweiler (12.5k6195201) | answered Oct 06 '14, 11:41 p.m.
You have to query for the list

here is similar code for BuildEngines..

hint IBuildDefinitionQueryModel

        ITeamRepository repo = (ITeamRepository) iprja.getOrigin();
        // get the data interface
        ITeamBuildClient buildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class);

        try
        {
            IBuildEngineQueryModel queryModel = IBuildEngineQueryModel.ROOT;
            // create a query for build engines
            IItemQuery query = IItemQuery.FACTORY.newInstance(queryModel);
            // objects of build engine type
            IPredicate isBuildEngineType = queryModel._isTypeOf(IBuildEngine.ITEM_TYPE);
            // allocate space for the parameter
            IItemHandleInputArg[] itemHandleArgs = new IItemHandleInputArg[] { query.newItemHandleArg() };
            // the query filter           
            IPredicate filter = ((BuildEngineQueryModel) queryModel).processArea()._in(itemHandleArgs);
            // set the query filter using the combined predicates             
            query.filter(isBuildEngineType._and(filter));
            // 1 parameter  required
            IItemQueryPage queryPage = buildClient.queryItems(query, new Object[] { iprja }, IQueryService.ITEM_QUERY_MAX_PAGE_SIZE, null);

            // if there are buildengines defined
            if (queryPage.getResultSize() != 0)
                while (queryPage != null)
                {
                    IFetchResult fetchResult = null;
                    if (allProperties == true)
                    {
                        fetchResult = repo.itemManager().fetchCompleteItemsPermissionAware(queryPage.getItemHandles(), IItemManager.DEFAULT, null);
                    }
                    else
                    {
Yung-Hsiang Chan selected this answer as the correct answer

Comments
Yung-Hsiang Chan commented Oct 07 '14, 2:20 a.m. | edited Oct 07 '14, 2:28 a.m.

Thanks! 

I got it!!!

Your answer


Register or 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.