Generate my own Tab in Teamcity that references to Artifacts contents

Hi,

I have been posting threads here but it seemed to confusing everyone so not getting replies.

Here, I have generated the JPEG picture that tells you what I have been looking for. Please go through the attached picture.

Basically, I have couple of Html files in "Artifacts -> Reports folder -> *.html" location. I want to create my own TAB just beside Artifact one and when someone clicks on that TAB, it should display all the html files available in report folder again in terms of the tabs as shown in picture.

Could anyone please guide me how could I proceed with this.

Thanks.



Attachment(s):
TeamCityTab.jpg
12 comments

TeamCity has HTML report tabs that are quite simple: they display static HTML.
You can probably generate such HTML inside your build script where you can list the reports that will be published as build artifacts.

More complex but moe dynamic approach is to write TeamCity Java/Groovy/JRuby plugin that will add a custom tab with arbitrary content to build results.

0

Thanks Yegor.

My problem is that, I want to have a fixed outside tab but the inner tabs would vary from 1 to 8. I am not sure how to iterate through Artifacts folder to get the all html files and create tabs for each as I mentioned in my original question. Do I need to write JavaScript or something? Can JavaScript runs on clicking my main tab?

Sorry but I am kind of new to TeamCity.

Thanks.

0

The suggestion that should work for your case is to add an additional build step to your build script that will interate through the files that will be published as artifacts for the build and generate HTML referencing the files. Then this accumulating file should also be published as build artifact and be displayed as a report tab.

You will not be able to do all these from JavaScript as there is no (at least documented) ability to list all the artifacts of a build via remote calls.

The solution with TeamCity plugin should also suite in your case.

0

Thanks Yegor for getting back on this.


>>
The suggestion that should work for your case is to add an additional  build step to your build script that will interate through the files  that will be published as artifacts for the build and generate HTML  referencing the files. Then this accumulating file should also be  published as build artifact and be displayed as a report tab.
<<

I presume you mean my NAnt build script. Could you please point out some examples that could access Artifacts files from build script and generate html page? It would be really great.

Thanks.

0

The approach I mean is:

- manually get the build's artifacts path cpecified in TeamCity
- list the files on disk inside the NAnt script using the knowledge from the previous step. This task can be as easy as listing files in a specific directory if you have artifact publishing pattern like "output" (publish all files from directory "output" as build's artifacts)
- use the file listing to generate required HTML

0

Yegor, I tried doing what are you saying with simple test case. Isn't publishing artifacts happen after the Build script executed? If I try to get the list of files from build script, it doesn't work and will gives following error:

[14:45:25]: C:\TeamCity\buildAgent\work\bf22f71253396f96\build8373648913643129294.tmp(15,5): Source directory 'C:\TeamCity\buildAgent\work\CustomReports' does not exist.
[14:45:26]: NAnt output:
[14:45:26]: NAnt 0.85 (Build 0.85.2478.0; release; 14/10/2006)
[14:45:26]: Copyright (C) 2001-2006 Gerry Shaw
[14:45:26]: http://nant.sourceforge.net
[14:45:26]: Buildfile: file:///C:/TeamCity/buildAgent/work/bf22f71253396f96/build8373648913643129294.tmp
[14:45:26]: Target framework: Microsoft .NET Framework 2.0
[14:45:26]: Target(s) specified: test
[14:45:26]: [loadtasks] Scanning assembly "NAnt.Contrib.Tasks" for extensions.
[14:45:26]: [loadtasks] Scanning assembly "Build.Tasks" for extensions.
[14:45:26]: [loadtasks] Scanning assembly "SystemTest.Tasks" for extensions.
[14:45:26]: BUILD FAILED
[14:45:26]: C:\TeamCity\buildAgent\work\bf22f71253396f96\build8373648913643129294.tmp(15,5):
[14:45:26]: Source directory 'C:\TeamCity\buildAgent\work\CustomReports' does not exist.
[14:45:26]: Total time: 0.1 seconds.
[14:45:26]: Publishing artifacts
[14:45:26]: [Publishing artifacts] Paths to  publish: [C:/Tests/CustomReports/*.*=>CustomReports, teamcity-info.xml]
[14:45:26]: [Publishing artifacts] Publishing files
[14:45:27]: Build finished


Please note that publishing artifacts happening fine and I could see the CustomReports folder under Artifacts.


Following is my Build script:




<?xml version="1.0" encoding="utf-8"?>
<project name="Testing" default="test" ....>

  <property name="customeReportDir" value="..\CustomReports" />  
  <property name="nant.contrib.tasks.dll" value="${path::combine(environment::get-variable('NANT_CONTRIB_HOME'), 'bin\NAnt.Contrib.Tasks.dll')}"/>
  <fail unless="${file::exists(nant.contrib.tasks.dll)}" message="Can't find NAnt.Contrib.Tasks.dll. Is NANT_CONTRIB_HOME set correctly?"/>
  <loadtasks assembly="${nant.contrib.tasks.dll}"/>

  <target name="test">   
           .......
  </target>
  
  <foreach item="File" in="${customeReportDir}" property="fileName">   
    <if test="${string::to-lower(path::get-extension(fileName)) == '.html'}">  
     <move file="${fileName}" tofile="${path::combine(path::get-directory-name(fileName), path::get-file-name-without-extension(fileName) + '.txt')}" />  
    </if>  
   </foreach>  

</project>


Please let me know if I am missting something.


Thanks.
0

Also I think C:\TeamCity\buildAgent\work\ or ${teamcity.build.workingDir} or C:\TeamCity\buildAgent\work\<some-unique-string> are not the correct folders it is looking into. I dont see the artifacts stored there. Which directory should I refer to get the Artifacts\CustomReports contents?

Morever, do we have something like post build script that runs after build is finished(successfully or with errors no matter).

I am also looking into writting TeamCity plugin option. It would be great if you could point me out something to start with. I am familiar with JAVA FYI.

Thanks for being there.

0

Hi Yegor, I got the nice reading stuffs about plugin developments at http://confluence.jetbrains.net/display/TCD4/Developing+TeamCity+Plugins

Could you please throw some light on "Post build script". How to setup it?

Thanks.

0

Yegor, Am I being too nut? :)

Let me make the question simple. I got to know that my html file is stored at http://localhost:8080/repository/download/bt2/93:id/CustomReports/ . Can I get the files inside CustomReports folder by any way?

Thanks.

0

Could someone please assist me here. If it is not possible to iterate through the files on above mentioned location, please let me know so. I am ready to give the required credentials while accessing TeamCity server files.

Thanks.

0

> Isn't publishing artifacts happen after the Build script executed

Yes, as you can see from the build log artifacts are published after the build script is finsihed.

> If I try to get the list of files from build script, it doesn't work and will gives following error:
> C:\TeamCity\buildAgent\work\bf22f71253396f96\build8373648913643129294.tmp(15,5): Source directory 'C:\TeamCity\buildAgent\work\CustomReports' does not exist.
...
> [Publishing artifacts] Paths to  publish: [C:/Tests/CustomReports/*.*=>CustomReports, teamcity-info.xml]

It seems you should be using "C:/Tests/CustomReports/" path instead of "C:\TeamCity\buildAgent\work\CustomReports"

Apparently, you should fix the line in your script:
<property name="customeReportDir" value="..\CustomReports" />
to something like:
<property name="customeReportDir" value="C:\Tests\CustomReports" />

> Also I think C:\TeamCity\buildAgent\work\ or ${teamcity.build.workingDir} or C:\TeamCity\buildAgent\work\<some-unique-string> are not the correct folders it is looking into.
> I dont see the artifacts stored there. Which directory should I refer to get the Artifacts\CustomReports contents?

This depends on the logic of you build script that produces the artifact, not on TeamCity.

As a side note, I'd note that it's not recommended to create new or modify files outside of the build checkout directory. At least at this level this cannot be managed by TeamCity anymore and you should bear affected paths in mind e.g. when installing another agent on the same machine or relying on TeamCity's clean checkout.

> I am also looking into writting TeamCity plugin option. It would be great if you could point me out something to start with. I am familiar with JAVA FYI.

Sample plugin that is included into devPackage has an example of a custom build tab.


> Could you please throw some light on "Post build script". How to setup it?

Current TeamCity 6.0 EAP builds already have ability to add manu build steps for a single build configuraiton.
In 5.1.x. you probably need to add the step inside your build script. Or do this in TeamCity agent plugin.

0

Thanks Yegor. That explains all.

It doesn't seem to possible(or difficult) to do on TeamCity. I have modified our intermediate system to deal with my issue.

Thanks.

0

Please sign in to leave a comment.