TeamCity Dashboard Plugin - Help Needed

I am developing a plugin for the TeamCity (TC) web UI that will add a tab to the top of pages that contain the TC standard navigation (Projects, My Changes, Agents, and Build Queue) and serve as a primary display for build status and history in one or more projects. The original page I wrote for this used the REST API which requires several dozen XML files be loaded to show a single set of status and history data. The loading times were terrible and we didn't get all the information we needed to easily display personal builds. This Topic is intended to serve as both a log of my progress and a solution when I'm stuck. Hopefully this can be a colaborative effort and we can all benefit from the effort.

So I'm starting fresh with a new plugin generated using ant from the template project, templatePrj. It looks like the environment is setup correctly, as shown by my auto-complete working with the TC classes. I am looking for a way to insert a new link between Projects and My Changes at the top of the page. Here is the relevant code I've got so far.

public class dashboard extends SimplePageExtension {
    public dashboard(PagePlaces pagePlaces) {
        super(pagePlaces, PlaceId.ALL_PAGES_HEADER, "Dashboard", "input.jsp");
        register();
    }
}

I cheated a little and just copied input.jsp from the sample plugin:
<%@ include file="/include.jsp" %>
<c:url var="actionUrl" value="/helloUser.html"/>
<form action="${actionUrl}" >
  <input id="search" type="submit" value="Click me!"/>
</form>


I compile it using ANT which I thought would copy the files needed to my local TC directories, but I don't see them there. There are some compiler warnings, although I don't know how to see what they are, but the build succeeds. Do I need to copy the files manually to the plugin folder?

6 comments
Comment actions Permalink

Hi Mitchell,

Thank you for the effort writing TeamCity plugin. BTW, do you plan to make it public?

Unfortunately, at this time there is no open-API way to add a new top-level tab (one next to Projects, My Changes, Agents, and Build Queue).
The only way to do that would be hacking the JavaScript to add a tab on client side on page load.

The extension you use (PlaceId.ALL_PAGES_HEADER) will add your code in the beginning of each HTML page rendered by TeamCity (if the code is functional, you should be able to see the injected piece of HTML if you view the page source).
However, it's up to the injected code to add the appropriate link.

Thankfully, this is not hard to do with the current client code, so I quickly hacked a sample implementation, see the topLevelExample.zip attached. dist\topLevelExample.zip is the pre-built plugin.
Please note that this is not an open API (read: can change in future TeamCity verisons without any extra note).


> Do I need to copy the files manually to the plugin folder?

Yes. The intended flow is that you call "ant"  in the plugin directory and then copy dist\<plugin_name>.zip under .BuildServer\plugins, then restart the server. That can be partly automated with the existing Ant script tasks.


As to REST:
> The loading times were terrible and we didn't get all the information we needed to easily display personal builds.

More detailed feedback is welcome: e.g. what was particularly slow and what data is missing



Attachment(s):
topLevelExample.zip
0
Comment actions Permalink

> BTW, do you plan to make it public?

Yes, I'd like to make this a public plugin barring any proprietary code gets inserted, which I doubt since this is meant to allow customization on the web UI.

> The intended flow is that you call "ant"  in the plugin directory and  then copy dist\<plugin_name>.zip under .BuildServer\plugins, then  restart the server. That can be partly automated with the existing Ant  script tasks.

Are there any samples of scripts like this? I've never scripted for Ant before so I appreciate any tips. Right now I've been using the integrated Ant task panel in the IDE to build with Ant. Is there a way to incorporate scripting into that interface?

As to REST:
>> The loading times were terrible and we didn't get all the information we needed to easily display personal builds.

> More detailed feedback is welcome: e.g. what was particularly slow and what data is missing

The problem with REST is not just REST itself but that the XML parser is slow. While loading a few XML files is not noticable, when you load hundreds it is very slow. With REST you can get a list of any number of changes/modifications submitted to your VCS easily and all the builds associated with that submission contain the change number as shown in the VCS. But since personal builds do not affect the VCS directly they don't get assigned a unique change number so builds can't be associated with a submission (when using VCS numbers as TC build numbers). This means to get a list of personal builds and associate them with a users submission to TC there is a lot of leg work and many extra XML files to load.

0
Comment actions Permalink

The pre-built package (dist\topLevelExample.zip) works but when I build the plugin myself it doesn't work. I'm using JDK 1.7 and it looks like you use 1.5. The only things I've changed are the JDK and the location of my TC server.

0
Comment actions Permalink

Mitchell,

> Are there any samples of scripts like this? I've never scripted for Ant before so I appreciate any tips. Right now I've been using the integrated Ant task panel in the IDE to build with Ant. Is there a way to incorporate scripting into that interface?

The script in the plugin can probably be used as an example. The one with <plugin_name>.xml is generated by IDEA via Build/Generate Ant Build... action.
You should also be able to add build.xml into "Ant Build" tool window of IDEA and run default task (the one in bold) from there.


> The pre-built package (dist\topLevelExample.zip) works but when I build the plugin myself it doesn't work.

Hard to tell anything definite based on this. teamcity-server,log should get any related plugin loading errors, if the issue is with JDK used.


> The problem with REST is not just REST itself but that the XML parser is slow.

You can also try to use JSON (requesting it via "Accept" header), but the parsing time will probably be about the same as for XML.

> But since personal builds do not affect the VCS directly they don't get assigned a unique change number so builds can't be associated with a submission (when using VCS numbers as TC build numbers). This means to get a list of personal builds and associate them with a users submission to TC there is a lot of leg work and many extra XML files to load.

I'd try to list only the builds in some time frame around the personal change time.
Any additional suggesitons in the area are welcome.

0
Comment actions Permalink

Ok so going back just a bit. When I open these samples and open-source plugins I get an error that Spring was missing (which I ignore). Here are some screens that I hope will shed some light on why it's not working. Where are these libs supposed to come from and why aren't they installed with TC if we need them to run plugins? If having these missing libs isn't the problem I've also downloaded JDK 1.6 and 1.5 so I can see if building with those changes anything.



Attachment(s):
IDEA-local.png
IDEA-missing.png
0
Comment actions Permalink

Mitchell,

The references to org.springframework*.jar files are coming for plugins not matching current TeamCity release. In the plugin I attached there are no references like that. It uses references to spring*.jar files instead.

0

Please sign in to leave a comment.