JetBrains / TeamCity.SonarQubePlugin

A plugin for TeamCity server allowing you to configure and run SonarQube analysis from the CI
Apache License 2.0
53 stars 31 forks source link

Unit Tests Are Not Getting Sent #22

Closed dlamanaancile closed 6 years ago

dlamanaancile commented 8 years ago

TeamCity: 9.1.2 build 37168 SonarQube: 5.6

We have unit tests on our .NET code being run via MSTest. When using the plugin, we cannot get the unit tests sent over to the SonarQube server and analysed. However, if we use the manual installation and add build steps to push the tests, everything works. We'd like to continue using the plug-in, but not have our units tests makes this a non-starter. Thoughts?

Linfar commented 8 years ago

Hi,

The goal is to point SonarQube to MSTest results file. Try to add "-Dsonar.cs.vstest.reportsPaths=%system.teamcity.build.tempDir%/TestResults.trx" to the SonarQube Additional arguments. Not sure the path is correct, you can find it in the build log. I'm sorry, I'm currently on vacation so I can't check the solution.

On Fri, Jul 15, 2016 at 10:28 PM, dlamanaancile notifications@github.com wrote:

TeamCity: 9.1.2 build 37168 SonarQube: 5.6

We have unit tests on our .NET code being run via MSTest. When using the plugin, we cannot get the unit tests sent over to the SonarQube server and analysed. However, if we use the manual installation and add build steps to push the tests, everything works. We'd like to continue using the plug-in, but not have our units tests makes this a non-starter. Thoughts?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JetBrains/TeamCity.SonarQubePlugin/issues/22, or mute the thread https://github.com/notifications/unsubscribe-auth/AETt8LXMqm8S9rq0CJOVX9dy8SCIr54Lks5qV99EgaJpZM4JNtmt .

Andrey Titov Software Developer JetBrainshttp://www.jetbrains.com The Drive to Develop

dlamanaancile commented 8 years ago

Hi,

Apologies for contacting you while you were on vacation. So it looks like we need to specify the *.trx files explicitly. When we do, we see a Code Coverage tab in TeamCity, but this info is not passed on to the SonarQube web app. If you look at the project in the web app, there is no Coverage section.

Cheers;

cnase commented 8 years ago

Hi Linfar, I work with Dean and had an opportunity to do some troubleshooting yesterday. In the TeamCity build log, I see "Generate dotCover HTML report" which took over 50sec but doesn't have any additional logging when I expand the node. My assumption is that this is the HTML report that needs to be pointed to by the sonarqube runner build step (-DSonar.cs.dotcover.reportsPaths=). The only HTML that I can find that is created by the plugin is inside a zip file called "coverage" at the following location (D:\BuildAgent\temp\buildTmp\dotCover4149648147985428188report). Should this zip file be getting unpacked into a location that we point our sonarqube runner build step to in order to get the coverage results to appear in the sonarqube website? This same zip file is stored on the main TeamCity server and we can see the Code Coverage results through Teamcity. It just isn't importing those results to the sonarqube website.

Linfar commented 8 years ago

Yes, you need to pass the report path to sonarqube runner. You could unpack the zip file created by TeamCity plugin or merge raw dotCover data as suggested in http://stackoverflow.com/questions/13170780/teamcity-dotcover-report-path-for-sonar/27153476#27153476 . Again I'm very sorry I can't check it works.

On Thu, Jul 21, 2016 at 4:36 PM, cnase notifications@github.com wrote:

Hi Linfar, I work with Dean and had an opportunity to do some troubleshooting yesterday. In the TeamCity build log, I see "Generate dotCover HTML report" which took over 50sec but doesn't have any additional logging when I expand the node. My assumption is that this is the HTML report that needs to be pointed to by the sonarqube runner build step (-DSonar.cs.dotcover.reportsPaths=). The only HTML that I can find that is created by the plugin is inside a zip file called "coverage" at the following location (D:\BuildAgent\temp\buildTmp\dotCover4149648147985428188report). Should this zip file be getting unpacked into a location that we point our sonarqube runner build step to in order to get the coverage results to appear in the sonarqube website? This same zip file is stored on the main TeamCity server and we can see the Code Coverage results through Teamcity. It just isn't importing those results to the sonarqube website.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JetBrains/TeamCity.SonarQubePlugin/issues/22#issuecomment-234254781, or mute the thread https://github.com/notifications/unsubscribe-auth/AETt8Cbim598ARPeck3rvVEdeRckVk-gks5qX3XMgaJpZM4JNtmt .

Andrey Titov Software Developer JetBrainshttp://www.jetbrains.com The Drive to Develop

cnase commented 8 years ago

I appreciate the response! We used the article to generate the coverageReport.html. We then have an argument on the sonarqube runner build step that says -DSonar.cs.dotcover.reportsPaths="%sonar.coverageReport%". We have %sonar.coverageReport% set as a parameter in TeamCity that is a direct path to the html file. We've confirmed in the log that this parameter is translating to the correct path of the html file. Unfortunately, the coverage results are still not being displayed on the sonarqube website and we don't see anything in the teamcity logs or the sonarqube logs. From our understanding, we should be able to pass over an HTML of the dotCover coverage report via the Sonar.cs.dotcover.reportsPaths argument and this should import the HTML to the sonarqube website correct? We must be missing something small at this point!

Linfar commented 8 years ago

Yes, html report should be passed to sonarqube runner through "-Dsonar.cs.dotcover.reportsPaths=" parameter. Could you send me the build log?

On Tue, Jul 26, 2016 at 4:09 PM, cnase notifications@github.com wrote:

I appreciate the response! We used the article to generate the coverageReport.html. We then have an argument on the sonarqube runner build step that says -DSonar.cs.dotcover.reportsPaths="%sonar.coverageReport%". We have %sonar.coverageReport% set as a parameter in TeamCity that is a direct path to the html file. We've confirmed in the log that this parameter is translating to the correct path of the html file. Unfortunately, the coverage results are still not being displayed on the sonarqube website and we don't see anything in the teamcity logs or the sonarqube logs. From our understanding, we should be able to pass over an HTML of the dotCover coverage report via the Sonar.cs.dotcover.reportsPaths argument and this should import the HTML to the sonarqube website correct? We must be missing something small at this point!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JetBrains/TeamCity.SonarQubePlugin/issues/22#issuecomment-235261972, or mute the thread https://github.com/notifications/unsubscribe-auth/AETt8PjfPT1MvesGKcq674EWYFazZZf8ks5qZgcMgaJpZM4JNtmt .

Andrey Titov Software Developer JetBrainshttp://www.jetbrains.com The Drive to Develop

dlamanaancile commented 8 years ago

Absolutely. Do you have an email address we can use to send that you? We'd rather not put that up on GitHub publically.

Linfar commented 8 years ago

Please send to andrey.titov@jetbrains.com

On Thu, Jul 28, 2016 at 5:07 PM, dlamanaancile notifications@github.com wrote:

Absolutely. Do you have an email address we can use to send that you? We'd rather not put that up on GitHub publically.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JetBrains/TeamCity.SonarQubePlugin/issues/22#issuecomment-235904948, or mute the thread https://github.com/notifications/unsubscribe-auth/AETt8DBmMIjYPm7vBIBMREMjzICmiBkbks5qaLe-gaJpZM4JNtmt .

Andrey Titov Software Developer JetBrainshttp://www.jetbrains.com The Drive to Develop

Linfar commented 8 years ago

Thanks. From what I see SonarQube runner didn't even try to analyze the coverage report (no appropriate Sensor was called). It seems SonarQube is case-sensetive so correct argument should exactly be "-Ds onar.cs.dotcover.reportsPaths".

On Thu, Jul 28, 2016 at 5:29 PM, Andrey Titov andrey.titov@jetbrains.com wrote:

Please send to andrey.titov@jetbrains.com

On Thu, Jul 28, 2016 at 5:07 PM, dlamanaancile notifications@github.com wrote:

Absolutely. Do you have an email address we can use to send that you? We'd rather not put that up on GitHub publically.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JetBrains/TeamCity.SonarQubePlugin/issues/22#issuecomment-235904948, or mute the thread https://github.com/notifications/unsubscribe-auth/AETt8DBmMIjYPm7vBIBMREMjzICmiBkbks5qaLe-gaJpZM4JNtmt .

Andrey Titov Software Developer JetBrainshttp://www.jetbrains.com The Drive to Develop

Andrey Titov Software Developer JetBrainshttp://www.jetbrains.com The Drive to Develop

samgooch commented 8 years ago

Did you manage to get this to work @dlamanaancile ?

dlamanaancile commented 8 years ago

Hi Sam,

No we have not gotten this to work. We have the manual scanner working, however.

Cheers;

Dino R. LaMana DevOps / Staff Software Engineer Email: dino.lamana@ancile.commailto:dino.lamana@ancile.com Phone: 1-443-561-3922

From: Sam Gooch [mailto:notifications@github.com] Sent: Thursday, August 18, 2016 8:23 AM To: JetBrains/TeamCity.SonarQubePlugin TeamCity.SonarQubePlugin@noreply.github.com Cc: LaMana, Dino dino.lamana@ancile.com; Mention mention@noreply.github.com Subject: Re: [JetBrains/TeamCity.SonarQubePlugin] Unit Tests Are Not Getting Sent (#22)

Did you manage to get this to work @dlamanaancilehttps://github.com/dlamanaancile ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/JetBrains/TeamCity.SonarQubePlugin/issues/22#issuecomment-240706878, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ANO0Adrw0ygzoI9i_h4JnMCgzgF4Olamks5qhE6NgaJpZM4JNtmt.

This message may contain confidential or privileged information and is intended only for the individuals addressed in the body of the email. Nothing in this message shall be construed as making or accepting an offer to form a contract unless this message is followed by a written signed confirmation. If you have received this message in error, please notify the sender and then delete the message and all copies. Thank you.

introllo commented 6 years ago

Same here using golang reports. When run using "sonar-scanner" coverage reports are displayed correctly in SonarQube web. However, when processed using the SonarQube runner, the coverage reports are ignored/not visible. I'm using the same sonar-project.properties file. How can I better debug where this breakdown is occurring?

I see this message coming from the TeamCity build log:

[14:14:21][Step 7/7] INFO: Sensor Go Coverage [golang] [14:14:21][Step 7/7] INFO: Analyse for /root/go/src/github.my-org.com/repo/package.git/coverage.xml [14:14:22][Step 7/7] WARN: unable to create InputFile object: /root/go/src/github.my-org.com/repo/package.git/vendor/github.com/docker/docker/pkg/tarsum/tarsum.go [14:14:22][Step 7/7] INFO: Sensor Go Coverage [golang] (done) | time=392ms [14:14:22][Step 7/7] INFO: Sensor Go test JUnit loader sensor [golang]

Don't see this when running with the sonar-scanner client.

Linfar commented 6 years ago

@introllo As I see in SonarQube golang integration code this message means Sonar has tried to find source file (pkg/tarsum/tarsum.go ?) and failed. Please check you have correct directories structure in the agent and Sonar Runner is executed with correct working directory.

introllo commented 6 years ago

Hi @Linfar I can confirm that file (and others) exist and is accessible to the user running the scan (root). The sonar runner is in correct working directory as other reports ARE being published.

Note: a file exists by that name in that location. I'm unclear what "create InputFile object" is doing here. Are we taking the file that exists and serializing it for processing? If we're just copying it to filesystem, then that worked. Here are the files in that dir...

/vendor/github.com/docker/docker/pkg/tarsum# ls -l total 76 -rw-r--r-- 1 root root 645 Nov 9 22:11 builder_context.go -rw-r--r-- 1 root root 1566 Nov 9 22:11 builder_context_test.go -rw-r--r-- 1 root root 3316 Nov 9 22:11 fileinfosums.go -rw-r--r-- 1 root root 1703 Nov 9 22:11 fileinfosums_test.go -rw-r--r-- 1 root root 7969 Nov 9 22:11 tarsum.go -rw-r--r-- 1 root root 8961 Nov 9 22:11 tarsum_spec.md -rw-r--r-- 1 root root 17006 Nov 9 22:11 tarsum_test.go drwxr-xr-x 6 root root 4096 Nov 9 22:11 testdata -rw-r--r-- 1 root root 4116 Nov 9 22:11 versioning.go -rw-r--r-- 1 root root 2460 Nov 9 22:11 versioning_test.go -rw-r--r-- 1 root root 260 Nov 9 22:11 writercloser.go

Linfar commented 6 years ago

I believe SonarQube Scanner tries to read the file to generate the coverage report but fails. Did you try running SonarQube Scanner from commandline using the same user as used to run TeamCity Agent build?

hydradon commented 6 years ago

Hi @Linfar ,

I am using IntelliJ Coverage runner in my TeamCity Gradle build step. In the next step I have SonarQube runner, but I don't know where the coverage report in the previous step gets stored ( I have no access to TeamCity build agent at my company ) so I wonder where the default location is so I can point -Dsonar.jacoco.reportPaths to it?

Secondly I have another attempt using gradle jacoco plugin to generate report. I have asked a question on StackOverflow https://stackoverflow.com/questions/47523010/feed-jacoco-coverage-report-to-sonarqube-using-teamcity-but-it-shows-0-coverage and yet the coverage info doesnt appear on SonarQube website. Please advise on what I've done incorrectly

Linfar commented 6 years ago

@hydradon It seems there is no IntelliJ Coverage integration in SonarQube yet. You can use JaCoCo though.

Please try to add "-Dsonar.java.coveragePlugin=jacoco" to the SonarQube Runner step as I've answered in the stackoverflow ticked

introllo commented 6 years ago

Have been retesting w/latest Sonar-Golang plugin. I no longer see this message. Thx.