How to show a custom page output in TeamCity build status window - teamcity

I want to publish a jpg graph image or a table of them in TeamCity's build status page.
I'm trying to use the plugin Build Result Decorator for TeamCity to add a results page which doesn't seem to be working as expected. Wonder if anyone has a solution. When installed it creates this area (highlighted below) in the build status page, and should render a html in there. But it shows a download file requestor instead of rendering the HTML.
Im testing with a basic page
<html><body>
<h1>hello TC</h1>
</body></html>
I've added that like this:
Here is the config as code along side the NUnit xml feature.
features {
feature {
type = "BuildResultDecorator"
param("artifactFilename", "status.html")
}
xmlReport {
reportType = XmlReport.XmlReportType.NUNIT
rules = "**/result.xml"
}
}
Has anyone got this working correctly ? Or is there an alternative to this?

Figured this out: This is possible without plugin.
Under the Project setting you add a Project Level report or Build level report (which will create a tab in either of those screens) and point it at a html artifact that you saved in the build. Then in Global settings you can either disable protection in a secured environment or specifically provide a URL to retrieve the html artifact.
Documented here
Publishing 3rd Party reports
Global settings for artifacts

Related

TeamCity REST API - update 'settings' for build configuration

I'm trying to use the TeamCity REST API to update settings against a build configuration. Specifically, the checkoutDirectory that in the UI is in the "Version Control Settings->Additional Options->Checkout directory" textbox...
The documentation talks about updating the "parameters", but not the settings.
If I do a GET on /app/rest/buildTypes/<id>, the results include both settings and parameters...
I've tried various combinations of PUT request to try to update this, but having no luck.
Interestingly, if I do a GET on /app/rest/buildTypes/<id>/parameters, I get this...
Which includes the ID in the URL.
But if I do /app/rest/buildTypes/<id>/settings, I get this...
Which doesn't include the ID. Not sure if that's a bug - or I've completely misunderstood the scope of these settings, and they're global, not per build config - but that's certainly not what I'm seeing in the UI.
Any ideas how to use the REST API to update these settings?

How to add a custom link in a multibranch Jenkins Pipeline

We are archiving a lot of html reports in a Jenkins pipeline (scripted Pipeline). These are accessible through a link "Last Successful Artifacts" on the job page as usual. But we would like to create an additional custom link that that points to one of these reports (that is being generated whether the build is successful or not).
I found the DocLink plugin, but it's not listed on the pipeline compatibility list and I'm not able to figure out how this eventually could be used in a pipeline.
The HTML Publisher Plugin is another one I was looking at. But it’s not suited for our use case, since it requires us to gather all reports and publish them again. It also puts all the content in an iframe, but all we need is link to one of the already archived html reports.
Here is a example to add summary links to a build
manager.createSummary("document.png").appendText("<a href='"+ pom.url + "'>View Maven Site</a>", false)
As that method accepts HTML and can be used for XSS you need to approve them.
https://jenkins.io/doc/book/managing/script-approval/
for more examples look here: https://wiki.jenkins.io/display/JENKINS/Groovy+Postbuild+Plugin
For pipeline the Badge plugin was extracted from the Groovy Postbuild plugin and if can create the summary using something like:
createSummary icon:'package.png', text: "<a href='$pom.url'>View Maven Site</a>"

Spring Maven deployed successfully uinsg Intellij to JBoss, but JBoss welcome page is still showing

This is my first ever Spring/maven/JBoss App. Basically, I am trying to follow the instructions here
I am using Intellij 2016.3.5, JBoss EAP 7.0.0
I tried to follow the instructions in the home page. I generated the war file following the steps below:
File => Project Structure
Artifacts => + => Web Application Archive
Create Manifest File which looked empty:
run successfully.
In the output it shows it connected to the server
it opens automatically the web page at http://localhost:8080. But it is still displaying the Jboss's welcome page.
The unnamed.war file is placed in ..\EAP-7.0.0\
At the end of there is the following added automatically:
<deployments>
<deployment name="unnamed.war" runtime-name="unnamed.war">
<fs-archive path="C:\Users\VAIO\EAP-7.0.0\unnamed.war"/>
</deployment>
</deployments>
What could have gone wrong in my steps above?
Update
After #CrazyCoder 's comment, I followed the documentation here, and enabled web Application, where the project modules looks like this now:
and the project structure:
It runs, and opens http://localhost:8080/unnamed/
But it displays the word forbidden now. Am I heading in the wrong direction?
I found the solution based on #CrazyCoder's comment. In a nutshell, I followed the documentation as follows
Download zip from here
Extracted initial folder from here (initial directory contains the project that I started with).
Import initial project to Intellij.
In Intellij, right click on the root project directory, and select Add Framework support .... Then select the Web Application check box in the dialog that opens. What we did here, is to enabling Web Application options as per the documentations here
Verify that Intellij has generated WEB-INF directory under your root project directory, and this directory contains the exploded war file. It does that automatically once you enable your Web Application option. Check here for more details.
Back to Spring tutorial here. Create new class hello/SampleController.java, and modify the pom.xml accordingly.
Intellij will prompt you to import the changes (if you did not enable auto import) to resolve the dependencies you modified in pom.xml. Import the changes
Assuming your JBoss is installed and configured, you do not need to do anything on the web server side. Intellij will handle that for you.
Choose run, then edit configuration, then choose your server (JBoss local in my case)
If all goes well, it will open the browser with empty page (or pages contains $ENDED$, as we did not add any content.
You can add static content to your html page index.jsp in my case, and change the body, and the title, then deploy again to display Hello World
You could eventually bind the returned value from hello/SampleController.java to your index page to display dynamic values.

Download build drop from hosted Team Foundation Service

Using the hosted Team Foundation Service at tfs.visualstudio.com, one has the option in a Build Definition to "Copy build output to the server" which creates a zip of the drop folder that can be downloaded over https via team web access. I really need to download this drop automatically, so I can chain input to the next stage in my build pipeline.
Unfortunately, the drop URL is not obvious, but can be created using the TfsDropDownloader.
TL;DR - I can't get the TfsDropDownloader to work, I'm hoping someone else has used this tool or a similar method to succesfully download a drop from https://tfs.visualstudio.com
Using the command line TfsDropDownloader.exe I can do this:
TfsDropDownloader.exe /c:"https://MYPROJECTNAME.visualstudio.com/DefaultCollection" /t:"ProjectName" /b:"BuildDefinitionName" /u:username /p:password
...and get an empty zip file with the correct build label name of the last successful build e.g. BuildDefinitionName_20130611.1.zip
Running the source code in the debugger, this is because the URL that is generated for downloading:
https://tflonline.visualstudio.com/DefaultCollection/_apis/resources/containers/804/drop/BuildDefinitionName_20130611.1.zip
..returns a content type of application/json, which is unsupported. This exception is swallowed by the application, but not before the empty zip file is created.
Is it possible the REST API on Team Foundation Service has changed in some way so the generated URL is no longer correct?
Note that I am using the "alternate credentials" defined on my Team Foundation Service account (i.e. not my live ID) - using anything else gets me TF30063: not authorized.
I got it working by using alternate credentials, but I also had to access the REST API via a different path.
The current TfsDropDownloader builds a URL that looks like this:
https://project.visualstudio.com/DefaultCollection/_apis/resources/containers/804/drop/BuildDefinitionName_20130611.1.zip
This returns empty JSON whenever I try to use it. I'm definitely authenticated, because if I tweak the URL to:
https://project.visualstudio.com/DefaultCollection/_apis/resources/containers/804/drop
I get a nice JSON listing of every single file in the drop, but no zip.
From spying on the SSL traffic to https://tfs.visualstudio.com with Fiddler I saw that clicking the "Download drop as zip" link I can see that there is another endpoint at:
https://project.visualstudio.com/DefaultCollection/ProjectName/_api/_build/ItemContent?buildUri=vstfs%3a%2f%2f%2fBuild%2fBuild%2f639&path=%2Fdrop
...which does give you a zip. The "vstfs%3a%2f%2f%2fBuild%2fBuild%2f639" portion is the URL encoded BuildUri.
So I've changed my version of GetServerPath in the TfsDropDownloader source to do this:
private static string GetServerPath(TfsConnection collection, IBuildDetail buildDetail)
{
var downloadPath = string.Format("{0}{1}/_api/_build/ItemContent?buildUri={2}&path=%2Fdrop",
collection.Uri,
HttpUtility.UrlPathEncode(buildDetail.TeamProject),
HttpUtility.UrlEncode(buildDetail.Uri.ToString()));
return downloadPath;
}
This works for me for the time being. Hopefully this helps someone else with the same problem!

AppHarbor Web.config transforms not being applied

I am developing an application in ServiceStack and am trying to sort out deployment on AppHarbor, however for some reason my web.config transforms are not being applied.
I had originally a Web.AppHarbor.config file and changed the Environment Setting to "AppHarbor" - once this failed to work after several updates, I gave up and changed the Environment setting to "Release" and copied the desired transformations into the Web.Release.Config file.
App gets deployed OK but config settings do not reflect the values in the transform file (I verify this by login on with twitter and seeing the callback url for Twitter Auth still tries to redirect me to localhost, which is one of the settings I change in my transform file)
I have also tried the transform tester tool and all works as expected.
Manually publishing the web application to a local folder correctly applies the transformations according to the selected configuration
Does anyone have this working? Is there something obvious I'm missing?
Thanks
It sounds like the Web.Release.config file is not included in the build output. You need to set the Build Action attribute to Content to include it in the build output.
You can confirm whether the file is included in the output by downloading the build from the log page.
I stumbled across this post because I was seeing the same lack of action myself. Upon closer inspection (about 15 times that is) of my Web.Release.config I realized one of the nodes in my config file was not marked xdt:Transform="Replace". Unsurprisingly it did nothing when deployed.

Resources