Getting _focus values from the REST API

Answered

I'm currently trying to generate links to my TeamCity build logs for failed builds that will be commented on where the build was triggered from. For convenience sake I want to include a _focus value in the link that correlates to where the failure in the build was, or even just getting the value for a certain step in the build. The only focus values I can find from the API are from the /app/rest/testOccurrences endpoint, but the configuration I am trying to implement this for doesn't have any tests. Is there any other way to get focus values from the API? 

0
3 comments

Hi Arman,

 

if you have build problems, instead of testOccurrences, you could try with "problemOccurrences". It does not have a "focus" value, but you can use log anchors:

<url>/app/rest/latest/problemOccurrences?locator=build:(id:<build_id>)&fields=problemOccurrence(logAnchor)

 

That should give you an anchor to create a link for the log. Could you give it a try

0

have to bump this
I get the logAnchor is useful when you redirect user to viewLog page, like so:

viewLog.html?tab=buildLog&logTab=tree&filter=debug&expand=all&buildId=<build id>&_focus=<logAnchor>

but the number of logAnchor doesn't match the line number of the downloaded build log
and I need to capture the exact line of error to my user, can you provide another variable for line number in ProblemOccurrence Object in future release??

0

Hello Philip,

Unfortunately adding such a variable would be quite complex as it requires lots of processing, and as such it is not likely that it will happen in a nearby future. Did you have a chance to try the workaround proposed by Denis?

Thank you,

Guilherme

0

Please sign in to leave a comment.