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

Retreive Build Result Activity programatically from Build Result

I would like to retrieve the Build Result Activity from the Build result from a given Build Definition.
And i have the below implementation to retrieve the Build result. But further from here, i need some hints to retrieve the build result activity. any hints would be of great help.


    String repoName = "MyRepositoryURL";
    String buildDefId = "MyBuildDefinitionID";
    try {
      ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(repoName);
      repo.login(new NullProgressMonitor());

      ITeamBuildClient buildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class);


      IBuildDefinition definition = buildClient.getBuildDefinition(buildDefId, monitor);

      // Build query for COMPLETED results of this definition
      IBuildResultQueryModel model = IBuildResultQueryModel.ROOT;
      IItemQuery query = IItemQuery.FACTORY.newInstance(model);
      query.filter(model.buildDefinition()._eq(query.newItemHandleArg())
          ._and(model.buildState()._eq(BuildState.COMPLETED.name())));
      query.orderByDsc(model.buildStartTime());

      // Fetch first page (limit to 10 results)
      IItemQueryPage page = buildClient.queryItems(query, new Object[] { definition.getItemId() }, 5,
//          IQueryService.ITEM_QUERY_MAX_PAGE_SIZE,
          monitor);

      // Convert handles to full results
      List<IBuildResultHandle> resultHandles = new ArrayList<>();
      for (Object o : page.getItemHandles()) {
        if (o instanceof IBuildResultHandle) {
          resultHandles.add((IBuildResultHandle) o);
        }
      }

      List<IBuildResult> results = repo.itemManager().fetchCompleteItems(resultHandles, IItemManager.REFRESH, monitor);

      for (IBuildResult result : results) {
        System.out.println(
            "Build: " + result.getLabel() + " | Status: " + result.getStatus() + " | State: " + result.getState());
      }
    }
    catch (Exception e) {
      e.printStackTrace();
    }
 

0 votes


Be the first one to answer this question!

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,079
× 419

Question asked: Sep 12 '25, 3:35 a.m.

Question was seen: 369 times

Last updated: Dec 09 '25, 7:06 a.m.

Confirmation Cancel Confirm