How to get the full build status (including tests, inspections etc)

Ie, in the builds list in teamcity, the build status is:
"Tests passed: 19; inspections total: 14, errors: 11" <-- how can I get this string in a plugin?

I'm currently watching for the server event "buildFinished" (public void buildFinished(SRunningBuild build)) and then I try and get some status messages using

build.getStatusDescriptor().getText() or build.getBuildStatus().getText(), but neither gives me the information I want. Is there a different event I can listen on, to get a SFinishedBuild instead?



The results I'm getting when using getStatusDescriptor().getText() are pretty odd. I'm not sure what it is supposed to print, but here are some example outputs:

Ie, example output when using build.getStatusDescriptor().getText():
"Tests passed: 19; Changes" (Changes? What changes?)
Then sometimes I get the very unsatisfying
"Running" (but you just finished??)
or when a build fails, I've seen a couple of cases of:

"Process exited with code 2; Fetch source files" (Sure, it failed, but what does the source files have to do with anything? (it was a normal build failure)

/Johan
1
2 comments

Johan,

The case is that the event gets SRunningBuild which calculates status string by a bit different rules then finished build.
This is a bit wrong design that stays for historical reasons. I filed an issue to correct this: TW-22027.

> "Tests passed: 19; inspections total: 14, errors: 11" <-- how can I get this string in a plugin?
Could you please try this code:
BuildsManager.findBuildInstanceById(build.getBuildId()).getStatusDescriptor().getText()
(you will need to call it on BuildsManager instance obtained via Spring)

0
Avatar
Permanently deleted user

Works great so far. I'll deploy it this afternoon and let you know if we run into any issues.

(We tried to use some code recommended in a previous thread before:
info = new InspectionInfo(myBuildServer, build.getBuildId()).getStatistics();, but that gives us nullptr exception in the cases where there is no inspection data.
)

Thanks!
/Johan

0

Please sign in to leave a comment.