How to add a filter to the build log tab?

First post so sorry if I missed guidelines on posting I couldn't seem to find any.
And I am new to TeamCity so I apologize for giving bad descriptions.

I am looking to add a new filter for the build log tab.

The important messages tab does not give me the results I would like.

I have a .jsp file that does filtering based on a logfile but I don't know how to give it to TeamCity.

Anyways how do you create a new filter for the build log tab?

Thanks, Alex

23 comments
Comment actions Permalink

Hello, Alex,

Currently there is no easy way to extend build log filtering.You can only do it by digging into TeamCity API and writing a plugin.
What particular filtering do you need for your logs?

0
Comment actions Permalink

Alright thanks.
That is what I have managed to create.

I have a filtering created, but basically something that identifies and highlights the errors in the logfiles.

Thanks, for your time.

0
Comment actions Permalink

Alex,
In TeamCity 7.0 EAP you can also find Error messages filter which shows only red messages on Tree view tab in build log. May be it will be useful for you.

0
Comment actions Permalink

When you say TeamCity 7.0 EAP is this the link that I should be looking at?
http://confluence.jetbrains.net/display/TW/REST+API+Plugin

Using the red messages as filtering does not seem to work.
For example this would be the result if I used the red messages

[11:32:13]: Step 2/4: Build C/C++ sources (Ant) (53m:24s)
[11:32:20]: [Step 2/4] -build.main.windows (53m:16s)
[11:32:20]: [-build.main.windows] if (53m:16s)
[11:32:20]: [if] exec (53m:16s)
[12:25:37]: [exec] exec returned: 1
[12:25:38]: [Step 2/4] Step Build C/C++ sources (Ant) failed



From this I cannot see where the error occured.
0
Comment actions Permalink

Alex,

TeamCity EAP page is http://confluence.jetbrains.net/display/TW/TeamCity+EAP

Not sure that I fully understand your case.
Probably you could attach your build log and describe what filtering result do you require.
You could also attach the custom filter sources that you've crated so that I'll be able to review them.

0
Comment actions Permalink

The EAP seems to have a lot of extra things.

Trying out the http://blogs.jetbrains.com/teamcity/tag/build-log/

I have added a build failure condition by having it match a string.

I was expecting the 'offending' line to be highlighted as well.

Is there a way to have the offending line highlighted?

0
Comment actions Permalink

Hello, Allex,

Seems that you need something like
http://youtrack.jetbrains.com/issue/TW-18117
Are you?

0
Comment actions Permalink

That would give the desired result.

0
Comment actions Permalink

Thank you for the feedback. Please vote for the provided issue. We'll work on it after releasing TeamCity 7.0.
If you have workarounded the problem with the help of a plugin, you may share it with other users.

0
Comment actions Permalink

I have voted for that issue.

In the mean time I have found this page.

http://confluence.jetbrains.net/display/TCD65/Web+UI+Extensions#WebUIExtensions-DevelopingaCustomTab

By the looks of it I can "Add a tab" on the build results page.

Unfortunately I don't exactly know how to start this process to add a page.

Do you know of any examples for this, or where a good place to look for examples would be?


I see the http://www.jetbrains.net/confluence/display/TW/Server+Profiling example but that seems to already be in the final stages and it is just shipped in.

0
Comment actions Permalink

Alex,

The main topic concerning developing TeamCity plugins is http://confluence.jetbrains.net/display/TCD7/Developing+TeamCity+Plugins

To add a custom build results tab you normally need to implement jetbrains.buildServer.web.openapi.ViewLogTab interface with constuctor


  public MyTab(WebControllerManager manager, SBuildServer server) {
    super("My Tab", "myTabId", manager, server);
    setIncludeUrl("myTab.jsp");
  }


In the fillModel(Map<String, Object> model, HttpServletRequest request) method you may retrieve information about build from request and filter the desired message.
myTab.jsp is for printing the found message from model.

You need to package the plugin in a special way described at http://confluence.jetbrains.net/display/TCD7/Plugins+Packaging and provide valid plugin descriptor.

As an example of creating custom tab please review https://github.com/JetBrains/teamcity-nuget-support/blob/v0.7/nuget-server/src/jetbrains/buildServer/nuget/server/show/NuGetDownloadedPackagesTab.java which is part of TeamCity NuGet support plugin.

Feel free to ask questions if any.
0
Comment actions Permalink

Hello

I have tried to make a new tab however I did not succeed.

My steps were that

I had tried to use the line
public class myTab extends ViewLogTab implements jetbrains.buildServer.web.openapi.ViewLogTab{
but get the error
The type ViewLogTab cannot be a superinterface of myTab; a superinterface must be an interface
So I used
public class myTab extends ViewLogTab{

to create the myTab.java file

I have created a 'bean' called
build-server-plugin-myTab.xml
and placed it in a folder called META-INF

(Because this was in eclipse I exported my package myTab which contained the .java file and the folder containing the .xml)

I then took the jar file and zipped it.

Then I copied the jar file to
C:\Documents and Settings\akeursten\.BuildServer\plugins

I then restarted the server by using
C:\TeamCity\bin>runAll.bat stop
C:\TeamCity\bin>runAll.bat start

And then checked for the tab.

I imagine my main problem is my bean file

<?xml version="1.0" encoding="UTF-8"?>
  <bean id="myTab"
          
          init-method="register">
        <property name="placeId" value="BUILD_RESULTS_TAB"/>
        <property name="pluginName" value="myPlugin"/>
        <property name="includeUrl" value="myTab.jsp"/>
    </bean>

Would you know what I am doing wrong?

And thank you for all the help!



Attachment(s):
eclipse.bmp
build-server-plugin-myTab.xml
myTab.java.zip
0
Comment actions Permalink

Hello, Alex,

You should pack your plugin in the following way (I mark folders with *):

myTab.zip
     server *
          buildServerResources *
               myTab.jsp        
          MyTab.class
          META-INF *
               build-server-plugin-myTab.xml
     teamcity-plugin.xml

Where MyTab.class is the compiled MyTab class from MyTab.java file.

build-server-plugin-myTab.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="constructor">
    <bean />
</beans>


and  teamcity-plugin.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<teamcity-plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:noNamespaceSchemaLocation="urn:shemas-jetbrains-com:teamcity-plugin-v1-xml">
  <info>
    <name>myTab</name>
    <display-name>My Tab</display-name>
    <version></version>
    <description>Additional build results tab for custom messages filtering</description>
    <vendor>
      <name></name>
      <url></url>
    </vendor>
  </info>
  <deployment use-separate-classloader="true"/>
</teamcity-plugin>

0
Comment actions Permalink

Alright,

So I had
teamcity-plugin.xml
server*
   buildServerResources*
       myTab.jsp
   META-INF*
       build-server-plugin-myTab.xml
   myTab.class

I took teamcity-plugin.xml and server and zipped to myTab.zip and put that .zip file into
C:\Documents and Settings\akeursten\.BuildServer\plugins
and then stoped and started the server and ran the build for a new build.

Looking at the tabs there does not seem to be any new Tab.

Looking at my files I don't seem to specify anywhere what the "PlaceID" should be.
Adding

<property name="placeId" value="PROJECT_TAB"/>

to my bean file does not seem to yield any results.

Eclipse also seems to think there is something wrong with the line

<!DOCTYPE beans PUBLIC -//SPRING//DTD BEAN//EN http://www.springframework.org/dtd/spring-beans.dtd>


"The public identifier must begin with either a single or double quote character."
But googling it seems that Spring uses that format so that seems to be alright.

I guess what a good question would be is there someway for me to check if the code gets loaded successfully?
I seem to have a "TeamCity Build Agent" but looking at it I don't see anything that would indicate a problem with the files.

Would you know where to go from here?

Edit*
Going to
Administration -> Plugin List
I can see the "myTab" under External plugins so I guess it is installing something.

0
Comment actions Permalink

Hello, Alex,

To detect if the plugin was loaded have a look at Administration  -> Server configuration -> Plugins WEB page (since TeamCity 7.0 it's Administration -> Plugins list page). If the plugin is loaded it should be present in the plugins list.
Could you please attach your myTab.zip and <TeamCity installation dir>/logs/teamcity-server.log.

0
Comment actions Permalink

I think these are the files you wanted to look at.

And looking at the plugin list it appears in the list.

Thanks again.



Attachment(s):
teamcity-server.log.zip
myTab.zip
0
Comment actions Permalink

Hello, Alex,

There are several issues in current plugin version. Seems that I didn't tell you everything accurately:

  • If your myTab class has is placed in myTab package, than it should be in myTab folder when you pack in into the plugin and bean class name in the descriptor should be myTab.myTab  (IMHO such naming can cause confusion and is not good)
  • Tag <bean> in build-server-plugin-myTab.xml is not closed
  • You should call resgister(); in myTab class constructor (see the mentioned above NuGetDownloadedPackagesTab.java as an example)
  • All server folder content should be put into myTab.jar archive (I mean buildServerResources, META-INF and myTab folders), so that correct plugin sctructure is



myTab.zip
     server *
          myTab.jar
               buildServerResources *
                    myTab.jsp
               myTab *  
                    myTab.class
               META-INF *
                    build-server-plugin-myTab.xml
     teamcity-plugin.xml

and build-server-plugin-myTab.xml should be:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
       default-autowire="constructor">
    <bean />
</beans>


I've managed to load your plugin with such a configuration on my local server, but the page still can't be displayed, because of non-correct path to jsp file.
For correct jsp path please see NuGetDownloadedPackagesTab.java.

0
Comment actions Permalink

Please also note that yesterday we've released TeamCity 7.0. and  http://youtrack.jetbrains.com/issue/TW-18117 fix will be present in one of nearest updates

0
Comment actions Permalink

Ah thank you that worked great!

I'm working on creating my JSP file now it works fine until I add the line

FileReader patternFile = new FileReader("pattern.txt");


Where pattern.txt is a file that is in the buildServerResources folder.

Restarting the server I the "myTab" tab is there and when clicking it I see "Unexpected Error"
Clicking on the show trace the main message is that
"javax.servlet.ServletException: File &quot;/plugins/myTab/hello.jsp&quot; not found"

Now I would understand if it said "pattern.txt not found", but hello.jsp is there and when I remove the FileReader line there is no problems.
Note: pattern.txt should also be found since it is in the same folder.

Searching on previous posts for "FileReader" I didn't get anything helpful so I imagine I'm doing something wrong.

Would you know what I'm doing wrong?

Thanks again.

Alex

0
Comment actions Permalink

Hello, Alex,

I'm not sure, but the error may be caused by java.io.FileNotFoundException. To learn more look through teamcity-server.log.

Try calculating the path to pattern.txt file in the myTab class fillModel method and putting it to model.
To get the correct path to pattern.txt use jetbrains.buildServer.web.openapi.PluginDescriptor#getPluginResourcesPath. Pass file path relative to buildServerResources folder to this method.
You can recieve this object in myTab class constuctor (have a look at NuGetDownloadedPackagesTab.java for an example).

To get the string from model in the jsp file use:
<jsp:useBean id="patternFilePath" scope="request" type="java.lang.String"/>

Let me know if it doesn't help.

0
Comment actions Permalink

And please also check that there is <%@ page import="java.io.*" %> directive in the beginning of your jsp file

0
Comment actions Permalink

I believe this fixed the problem

FileReader patternFile = new FileReader("C:/TeamCity/webapps/ROOT" + myPath);

Thank you.

0

Please sign in to leave a comment.