[Solved] How to find how long a build has been queued - java api. (or how to get IBuildRequest from IBuildResult)
Using the java api - how do I find out how long a build has been queued?
I've got the IBuildResult but don't know how to get the corresponding IBuildRequest I've 2 use-cases: 1) When a build starts I wish to log (in a DB) how long it has been waiting so we've a record of how bad our queue times are, and a record of total time from request to completed build. 2) I want to see how long builds are queuing for each build definition. This is so I can warn if builds have been queued for too long for a certain definition. I can then also add build engines to supports the definitions with the longest queues. In both cases we've got the IBuildResult already. In (1) we use the IBuildResult already to tag the build and for use case 2, I use an IItemQuery to find build results for definition X in BuildState.NOT_STARTED I've tried IBuildResult.getBuildRequests() but that only returns an empty List. Presumably if I could get to an IBuildRequest I could use IBuildRequest.getCreated() to find when it was queued? |
One answer
It turns out that was on the right track using IBuildResult.getBuildRequests() which was returning an empty list of IBuildRequestHandles.
My problem was I'd not actually got the full IBuildResult, I'd only got a partial IBuildResult. Mainly PEBKAC but I was thrown by the lack of documentation (I must accept there is no javadoc and just get the source), and but the List of requests - I don't understand how a build would have multiple requests. The following seems to do very roughly what I was wanting (null checks etc omitted for brevity) public void processBuildQueue(ITeamBuildClient buildClient) throws TeamRepositoryException { IItemQuery query = IItemQuery.FACTORY.newInstance(IBuildResultQueryModel.ROOT); |
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.