SonarQube 7.1 and TFS 2018 Publish Quality Gate Results Fail - tfs

Created a build definition in TFS 2018
Add step Prepare analysis on SonarQube.
3 Tokenizer: Transform Source Files
NuGet Restore
Build Solution: .NET
VsTest - testAssemblies
Run Code Analysis
Publish Quality Gate Result
Step 8 Fails with below error:
Evaluating condition for step: 'Publish Quality Gate Result'
Evaluating: succeeded()
Evaluating succeeded:
(Boolean) True
Expanded: True
Result: True
Starting: Publish Quality Gate Result
==============================================================================
2018-06-04T17:34:41.6970611Z Task : Publish Quality Gate Result
2018-06-04T17:34:41.6971068Z Description : Publish SonarQube's Quality Gate result on the VSTS/TFS build result, to be used after the actual analysis.
2018-06-04T17:34:41.6971496Z Version : 4.2.0
2018-06-04T17:34:41.6971818Z Author : sonarsource
2018-06-04T17:34:41.6972216Z Help : More Information
2018-06-04T17:34:41.6972761Z ==============================================================================
agent.TempDirectory=D:\source\agent\_work\_temp
loading inputs and endpoints
loading
ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
loading INPUT_POLLINGTIMEOUTSEC
loading SECRET_SONARQUBE_ENDPOINT
loaded 5
Agent.ProxyUrl=undefined
Agent.CAInfo=undefined
Agent.ClientCert=undefined
Agent.SkipCertValidation=undefined
SONARQUBE_SCANNER_PARAMS={"sonar.host.url":"http://localhost:9000/","sonar.login":"admin","sonar.password":"admin","sonar.projectKey":"nao-webapi","sonar.projectName":"nao-webapi","sonar.projectVersion":"1.0","sonar.cs.vscoveragexml.reportsPaths":"**/*.coveragexml","sonar.verbose":"true"}
SONARQUBE_ENDPOINT=********
API GET: '/api/metrics/search' with query "{"f":"name","ps":500}"
Response: 401 Body: "undefined"
API GET '/api/metrics/search' failed, status code was: 401
Could not fetch metrics
Processed: ##vso[task.issue type=error;][SQ] Could not fetch metrics
API GET '/api/metrics/search' failed, status code was: 401
Processed: ##vso[task.issue type=error;][SQ] API GET '/api/metrics/search' failed, status code was: 401
Agent.BuildDirectory=D:\source\agent\_work\21
defaultRoot: 'D:\source\agent\_work\21'
findOptions.followSpecifiedSymbolicLink: 'true'
findOptions.followSymbolicLinks: 'true'
matchOptions.debug: 'false'
I get the results, can't figure out why this is not working.

The extension site indicates, SonarQube extension works with:
Visual Studio Team Services
Team Foundation Server 2017 Update 2
Team Foundation Server 2017 Update 3
Team Foundation Server 2018
No TFS 2018 Update 2 yet.

Related

I am trying to send Jenkins data with InfluxDB plugin into the InfluxDB; it displays 'unauthorized access'

[InfluxDB Plugin] Collecting data...
[InfluxDB Plugin] Publishing data to target 'POC' (url='http://localhost:8086/', database='SOP')
ERROR: Build step failed with exception
com.influxdb.exceptions.UnauthorizedException: unauthorized access
at com.influxdb.internal.AbstractRestClient.responseToError(AbstractRestClient.java:114)
at com.influxdb.internal.AbstractRestClient.execute(AbstractRestClient.java:83)
at com.influxdb.client.internal.AbstractWriteBlockingClient.write(AbstractWriteBlockingClient.java:85)
at com.influxdb.client.internal.WriteApiBlockingImpl.lambda$writePoints$1(WriteApiBlockingImpl.java:137)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:723)
at com.influxdb.client.internal.WriteApiBlockingImpl.writePoints(WriteApiBlockingImpl.java:137)
at com.influxdb.client.internal.WriteApiBlockingImpl.writePoints(WriteApiBlockingImpl.java:121)
at jenkinsci.plugins.influxdb.InfluxDbPublicationService.writeToInflux(InfluxDbPublicationService.java:397)
Caused: jenkinsci.plugins.influxdb.InfluxReportException
at jenkinsci.plugins.influxdb.InfluxDbPublicationService.writeToInflux(InfluxDbPublicationService.java:400)
at jenkinsci.plugins.influxdb.InfluxDbPublicationService.perform(InfluxDbPublicationService.java:330)
at jenkinsci.plugins.influxdb.InfluxDbPublisher.perform(InfluxDbPublisher.java:227)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:80)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:818)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:767)
at hudson.model.Build$BuildExecution.cleanUp(Build.java:189)
at hudson.model.Run.execute(Run.java:1947)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
at hudson.model.ResourceController.execute(ResourceController.java:107)
at hudson.model.Executor.run(Executor.java:449)
Build step 'Publish build data to InfluxDB' marked build as failure
Environment: Windows, Google Chrome,
Expected Result: Jenkins data shall display in the InfluxDB/Graphs
Actual Result: While I test connection it displays success but upon running it displays 'ERROR: Build step failed with exception com.influxdb.exceptions.UnauthorizedException: unauthorized access'
On the InfluxDB side it displays 'Jenkins' under measurements but it says no result on submit

integrating sonarqube with jenkins insufficient privileges error

I followed this video https://www.youtube.com/watch?v=jh7utASgKj4 to integrate sonarqube with jenkins. However, I get the insufficient privileges error when scanning the code by sonarqube server. The version of sonarqube server is 6.7. how can I solve this problem?
Here is the analysis properties in the jenkins project
# Required metadata
sonar.projectKey = test-sonar
# Path to source directory
sonar.sources = /var/jenkins_home/workspace/$JOB_NAME/test-sonar/src
# bind sonar.java.binaries property
sonar.java.binaries=/var/jenkins_home/workspace/$JOB_NAME/test-sonar/target/classes
Here is the output of console.
INFO: SCM provider for this project is: git
INFO: 16 files to be analyzed
INFO: 16/16 files analyzed
INFO: 5 files had no CPD blocks
INFO: Calculating CPD for 8 files
INFO: CPD calculation finished
INFO: Analysis report generated in 132ms, dir size=124 KB
INFO: Analysis reports compressed in 48ms, zip size=61 KB
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 48.028s
INFO: Final Memory: 15M/304M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Insufficient privileges
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?
ERROR: SonarQube scanner exited with non-zero code: 1
If you are running the Sonar Analysis via Execute shell plugin for Jenkins, you need to supply the Username Password of a User which has the Execute Analysis rights on the SonarQube server you are trying to access.
To supply the username in the shell, you can use
-Dsonar.login=yourLoginName -Dsonar.password=*****
To set the Execute Analysis permission you can ask your DevOps team to give you access or if you are looking into that,
Goto Administration > Security > User/Groups.
Please make sure that you configure the Sonarqube UserID and Password having privileges to access sonar server (execute analysis permissions) in the Sonar plugin for Jenkins. This error might appear for 5.3 and higher versions when the anonymous access to sonar is disabled.

TFS 2015 Build: Test results not being published

I'm having a really weird error when TFS 2015 executes an automated test step.
The results are generated, but it seems TFS unable to find them.
In the end, it just says that no results were found to publish (which is weird, because it even outputs the result full path)
Check below the build logs for more info:
2015-12-16T15:44:29.5816976Z Executing the powershell script: C:\TfsBuildAgents\VsoBuildAgent\tasks\VSTest\1.0.22\VSTest.ps1
2015-12-16T15:44:29.7066995Z ##[debug]Calling Invoke-VSTest for all test assemblies
2015-12-16T15:44:30.4723241Z Working folder: C:\TfsData\Build\_work\1
2015-12-16T15:44:30.4723241Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "C:\TfsData\Build\_work\1\s\Rx.Api.V2.Tests\bin\Rx.Api.V2.Tests.dll" /Settings:"C:\TfsData\Build\_work\1\s\Staging.runsettings" /EnableCodeCoverage /inIsolation /logger:trx
2015-12-16T15:44:30.7379639Z Microsoft (R) Test Execution Command Line Tool Version 14.0.24720.0
2015-12-16T15:44:30.7379639Z Copyright (c) Microsoft Corporation. All rights reserved.
2015-12-16T15:44:30.9567007Z Starting test execution, please wait...
2015-12-16T15:44:38.2067012Z Passed Login
2015-12-16T15:44:39.6129523Z Passed GetMyEndpoints
2015-12-16T15:44:39.6129523Z Passed GetEndpoint
2015-12-16T15:44:42.3648007Z Passed Impersonate
2015-12-16T15:45:23.0904977Z Passed SingleHotel_BookTwoPaxesOnSingleRoom
2015-12-16T15:45:50.8053379Z Passed SingleHotel_BookOnePaxOnSingleRoom
2015-12-16T15:46:20.5444670Z Passed SingleHotel_BookFourPaxesOnTwoRooms
2015-12-16T15:46:53.4013344Z Passed SingleHotel_BookFourPaxesOnFourRooms
2015-12-16T15:47:03.3137055Z Passed Location_BookOnePaxOnOneRoom
2015-12-16T15:47:03.5168256Z Results File: C:\TfsData\Build\_work\1\s\TestResults\LOCAL SERVICE_YODA 2015-12-16 15_44_38.trx
2015-12-16T15:47:03.5168256Z Attachments:
2015-12-16T15:47:03.5324554Z C:\TfsData\Build\_work\1\s\TestResults\46904440-50c9-4522-b3c8-a84356b83b27\LOCAL SERVICE_YODA 2015-12-16 15_44_33.coverage
2015-12-16T15:47:03.5324554Z Total tests: 9. Passed: 9. Failed: 0. Skipped: 0.
2015-12-16T15:47:03.5324554Z Test Run Successful.
2015-12-16T15:47:03.5324554Z Test execution time: 2.4823 Minutes
2015-12-16T15:47:03.6887046Z ##[warning]No results found to publish.
In your runsettings file, comment out the ResultsDirectory tag under the RunConfiguration section.

How to filter files in sonar SCM?

I have installed a CI environment for my PHP project.
I use jenkins + sonar + Gitlab.
All things seem great until build a jenkins job.
The error info is
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 2:03.218s
Final Memory: 345M/456M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: Unable to blame file src/apps/conf.php. No blame info at line 1. Is file commited?
10:21:17.165 INFO - Author: PersonIdent[Not Committed Yet, , Wed Feb 4 10:21:17 2015 +0800]
ERROR:
I find sonar SCM-Activity-Plugin report this bug.
The conf.php file is my config file and can not push to Gitlab.
So, Is there a way to ask SCM-Activity-Plugin filter these config files?
thanks a lot!
Excluding the file from sonar analysis might help.
Login to sonar using admin or user that have got administrative rights in the project.
Open the project and select “Settings” from “Project Configuration”.
There click on “Exclusions” link and take “File” tab.
Under “Source File Exclusions” give your file as src/apps/conf.php

SonarQube BuildBreaker plugin not working

I have installed SonarQube 4.1.1, Jenkins ver. 1.533 and the BuildBreaker plugin.
I have set up two alerts in Sonar where if a certain threshold are reached it should flag the build on Jenkins as ERROR so I would expect to the something like this below in the log:
[ERROR] Coverage < 50%
[ERROR] Class complexity > 20
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Can not execute Sonar
Embedded error: Alert thresholds are hit (2).
The two alerts I have set is Blocker issues > 20 and Critical issues > 30.
And I have more then 20 Critical issues.
Yet when I run a Jenkins build in Preview mode sonar.analysis.mode=preview the build is successful.
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
Total time: 8:30.621s
Final Memory: 51M/916M
INFO: ------------------------------------------------------------------------
Recording test results
Finished: SUCCESS
Any ideas as to why Jenkins is not picking up the alerts from the BuildBreaker plugin?
If I go to the SonarQube Dashboard I can see the Critical issue > 30 alert has been reached.
Thanks,
IIRC build breaker is excluded by default in preview mode. You will want to check your preview configuration.
It looks like Since SonarQube 4.1, the buildbreaker plugin is excluded from incremental and preview execution mode by default. You may check your SonarQube settings ("Settings" -> "General Settings" -> "General") and add "buildBreaker" into "Plugins accepted for Preview and Incremental modes" input box, save the setting and try again.

Resources