VSTS SonarQube cannot find TRX file - msbuild

I am using Visual Studio Team Services to carry out an automated build, and using SonarQube to display Code Quality, Coverage, etc. I am also using a privately hosted build agent.
The build steps all work successfully with data being processed and populated through to SonarQube which is great. However, no code coverage is being displayed in SonarQube. After looking through the logs in VSTS I found that SonarQube is looking for the .trx file (which contains code coverage) in a different directory to the one that VSTS publishes the .trx file to.
So when VSTS builds the solution it creates the test results file here: C:\agent_work\3\s\TestResults
But SonarQube is trying to use test results from here: C:\agent_work\3\TestResults
On the build server, if I manually copy the .trx file into the correct location and then run the build again, the code coverage all works fine and processes through to SonarQube. So the issue is definitely the mismatch of the locations where the .trx is published and where it is to be picked up form.
I can't find a way of changing the publish location, or the SonarQube source location.
Please help!

This is a known issue, and will be fixed by the next release. See: https://jira.sonarsource.com/browse/SONARMSBRU-262.
We just announced the RC versions of the products that have this fix, you can give them a try. See this thread.

Related

Allure Reports Team City plugin causing builds to just hang on build step that runs tests

I'm trying to get allure reporting working as part of an NUnit project in C# using Selenium WebDriver. Following the documentation for installing allure seems to work fine on a local machine but I'm trying to get the Team City plugin to also work this the project. I've uploaded the allure team city plugin and added a build step that will generate a report even if the build fails or is stopped. The project has all the required allure nunit tags added and again this generates results locally that a report can be generated from. However, when running tests from Team City the build hangs and does not even begin to run tests. At the step that it should start running tests it just sits there. The Team City build logs do not show anything wrong. I'm using NUnit 3.6, Team City 2018.1, allure 2,7, allure team city plugin 2.9.
Does anyone have any experience with allure reporting? The documentation is a little out of date but I've done as much as I can with it.
I'm not sure if this is allowed, answering your own question, but in light of little on the ground of existing responses given the Allure developers actually suggest posting to this site as opposed to posting to their own Git hub site, I find it rather frustrating that there has been little response.
Anyway, having spent further hours looking into this I believe that the hanging of the builds is purely down to the allure-config.json file and the path to the allure-results setting within it. Any attempt to change that setting from its default appears to instantly cause the TC builds containing Allure Reports to hang.
hopefully this may help others having similar issues in future.

How to get Selenium tests to run after deployment in visual studio team services

I am having an issue getting selenium end to end tests to work after an automated deployment using visual studio team services (VSTS).
I have a build working that generates a build artefact. This is triggered from VSTS but runs on an on premises build server. I have a deployment working that deploys to an on premises development web server. All this works including unit tests running after the build.
When I try to add testing after the deployment is when I run into the problem. The tests are to be run on the build server and point to the dev server website. The deployment has two phases. A deploy and then an agent phase that runs a test assemblies task using the build agent on the build server. The problem seems to be that the test dll's are not being included in the build artifact and so are never found when the test process runs. Deploy setup us as follows.
I have a copy files before the publish artifact in the build definition that seems to copy the files in to the right place but they are not included in the zip file artefact. I've looked at several websites and posts on here but I still seem to be missing a vital bit of knowledge that will get this working.
Use of the log did help as recommended so thanks for that.
I have managed to get this working. I separated the selenium tests out into a separate solution and built that separately creating it's own build artefact. I then added this to the agent task in the deploy. This worked. The only thing I need to get sorted now is the correct search path to find the test DLL's. It's not quite as dynamic as I would like at the moment. I can play tunes on that until I get it right though.
I accept this is working around rather than solving the original problem but needs and timescales must. I think moving the end to end UI tests out of the main solution makes sense anyway but no doubt others may think differently.
Thanks for your help everyone

How to configure TeamCity to run last successful build on failure?

We're currently using TeamCity Enterprise 9.0 for our continuous deployment process; so please imagine the following scenario, you deploy your latest code to the dev branch, but one of the nugget packages was removed from the source and the build fails, QA team comes in at night and finds the build is broken and the environment is down for testing.
So I was wondering if there is a way to configure TeamCity to automatically run the last successful build in case the current code version fails, like configure it to make it aware that the current branch is broken and thus go back to a previous stable state.
Thanks,
The recommended approach is to have a separate build configuration for Deployment task. In this case you will be able to configure artifact dependency with option get artifacts from "Latest successful build".
Also see how to set up deployment with TeamCity.

Using MS Build to deploy after tests

I have a web project structured the following way:
WebSite
WebSite.test
In the test project, I have all the unit tests (using Microsoft test framework). In the WebSite project I have a target to deploy the site using MSDeploy, the MSDeployPublish target, and DeployOnBuild=true. I then run this build using Jenkins. The problem is that using this setup, the site will get deployed before it's tested.
I could add another build step in Jenkins, so that the entire solution is built first, then the deploy projects are run. However, I would like for it all to be in one step. Is this at all possible?
This is probably a bug in Jenkins. See this bug (or this one). See comments for possible workarounds.

Bamboo Integration

This is my second question on Bamboo (My First One). My understanding after reading suggested info, I need a build tool, like nAnt or MSbuild to write a script that gets the source code and builds it (I am working on a .net 3.5 with silverlight project). After, when deploying, I need to write scripts to move my files to the diff servers. Please tell me whether I am going in the right direction or not. Can I use ant, maven, bash scripts to do the same with a .net project?
Yes, that is true:
Bamboo is the central management server which coordinates all work
Bamboo itself has interfaces and plugins for lots of types of work
Bamboo basically needs to first get your source from a source repository (lots of plugins here for a variety of systems)
Then it needs to do the build - that can be done by using MSBuild to build your Visual Studio solution, or it could be a batch file to call your XYZ compiler and linker to create your app - whatever it is you have and use
Once your solution or project is built, you have "artifacts" (build results, e.g. executable app, config files, etc.) lying around
with those results, you can do additional things:
zip them up into a ZIP file and copy them somewhere
run a install builder on them and create an MSI
install them on a test server to make sure everything installs just fine
The sky's the limit! :-)
But in general: Bamboo is just the "orchestrator" - the coordinator. The actual work is done by either direct Bamboo plugins (of which there are plenty), or then you can call external command-line apps by means of a unix script or Windows batch file.
Marc