我想在Jenkins 2.x管道中执行"SonarQube扫描仪"步骤.
当我尝试在管道语法中创建一个示例groovy时,我只获得了以下格式的groovy脚本:
step <object of type hudson.plugins.sonar.SonarRunnerBuilder>
Run Code Online (Sandbox Code Playgroud)
有谁知道什么是正确的步骤语法?例如发布JUnit报告
step([$class: 'JUnitResultArchiver', testResults: ''])
Run Code Online (Sandbox Code Playgroud)
我使用以下版本:
我正在通过Jenkins构建执行声纳,有一个用例,其中'src'位置根据构建而改变,所以我想使用环境变量来指定'src'路径.
例如在sonar-project.properties中我想指定如下所示:
src= c:/project/workspace 相反,我想使用 src =${SONAR_RUN_WORKSPACE}
使用Jenkins 1.642.2对我所有的maven项目使用SonarQube 5.6.1进行代码分析.
当我使用maven目标声纳:声纳时,他们需要更多时间来分析文件(按文件超过7秒):
[INFO] Sensor SCM Sensor
[INFO] SCM provider for this project is: svn
[INFO] 1079 files to be analyzed
[INFO]
[INFO] 2/1079 files analyzed
[INFO] 3/1079 files analyzed
[INFO] 4/1079 files analyzed
[INFO] 5/1079 files analyzed
Run Code Online (Sandbox Code Playgroud)
当我使用带有此配置的SonarQube扫描仪时:
然后我有这个错误:
WARN: Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer …Run Code Online (Sandbox Code Playgroud) 在Debian杰西我不得不使用PostgreSQL(最新的杰西)的Java 8安装我在升级过程中去(到v.6.4)SonarQube 6.2的安装版本在这里
当它重新上线时,所有项目都丢失了.我可以通过手动输入项目的URL来获取它们,如:
https://[address of server]/dashboard?id=[Name of Project]
在用户管理部分(管理>安全>用户)中,我看不到用户.但是,如果我转到组(管理>安全>组),我的声纳用户组称它有用户.在我的情况下它14 - 但我看不到他们中的任何一个.谁能帮助把这些东西带回来?在升级之前我确实做过数据库备份 - 所以我总是可以回去,但我不想那样做.
声纳扫描仪对安装在 SonarQube 中的所有可用插件运行分析。但是对于某些项目,分析应该只针对某些语言(例如 Java 和 Javascript)运行。
sonar.language参数允许我只设置一种语言。有没有办法设置多种语言进行分析。
我正在扫描一个ui项目。
源代码在typescript.
gulp test-coverage生成.js文件(然后扫描覆盖范围)。(每个.ts文件.js旁边都有一个文件,位于同一位置)
我将扫描仪指向lcov.info文件,如下所示:
sonar.javascript.lcov.reportPaths=test-coverage/lcov.info
Run Code Online (Sandbox Code Playgroud)
问题:
的lcov.info,提供覆盖信息.js文件
出于某种原因,SonarQube 还提供了*.ts文件的覆盖率信息(尽管未包含在测试覆盖率报告中)。
这是为什么?
如果我明确使用
sonar.inclusions=**/*.ts
Run Code Online (Sandbox Code Playgroud)
或者
sonar.language=ts
Run Code Online (Sandbox Code Playgroud)
这些.js文件将从覆盖率报告中被忽略
如果我使用
sonar.coverage.exclusions=**/*.ts
Run Code Online (Sandbox Code Playgroud)
并没有具体的夹杂物,这将导致两者的.ts和.js被扫描的错误,这将在重复的错误最终文件(毕竟,.js由它们生成的文件.ts同行。
有什么建议?
整个问题当然会消失,如果 sonarqubelcov.info不采取措施扫描其他文件。)
晚上好,
我在Jenkins的2.1项目中使用.Net Core 2.0版本https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild:
withSonarQubeEnv('SonarQubeMain') {
bat "dotnet ${globals.SONAR_QUBE_MSBUILD_PATH}\\SonarScanner.MSBuild.dll begin /k:\"${globals.SONAR_QUBE_PROJECT}\" /d:sonar.host.url=${globals.SONAR_HOST_URL} /d:sonar.cs.xunit.reportsPaths=\"XUnit.xml\" /d:sonar.cs.opencover.reportsPaths=\"coverage.xml\"
}
bat "dotnet build --version-suffix ${env.BUILD_NUMBER}"
dir('test/mytestprojecthere') {
bat 'D:\\OpenCover\\OpenCover.Console.exe -target:"c:\\Program Files\\dotnet\\dotnet.exe" -targetargs:"xunit --no-build -xml XUnit.xml" -output:coverage.xml -oldStyle -filter:"-[*Tests*]*" -register:user'
}
withSonarQubeEnv('SonarQubeMain') {
bat "dotnet ${globals.SONAR_QUBE_MSBUILD_PATH}\\SonarScanner.MSBuild.dll end"
}
Run Code Online (Sandbox Code Playgroud)
它适用于第一个构建,但在下一个构建中,它失败了:
Failed to create an empty directory 'D:\Jenkins\workspace\xxxxxxxx\.sonarqube'.
Please check that there are no open or read-only files in the directory and that you have the necessary read/write permissions.
Detailed error message: Access to the path …Run Code Online (Sandbox Code Playgroud) 所以我在我的文件中有下面的代码行
List<String> nameList = new ArrayList<String>();
Run Code Online (Sandbox Code Playgroud)
现在我每次运行声纳扫描时都会在上面的行中显示错误,说我应该使用菱形运算符.现在我明白从Java7编译器会自动检测并提供ArrayList的对象类型,但我的问题是,如果我自己在声明类时这样做有害吗?
这是Sonar网站的规则链接.我真的不明白他们提供这个规则的例子.
在将代码更改为Sonar建议的内容时,是否有任何性能,效率或任何其他类型的收益?
我一直在做一些研究。我发现是相当不错的样本,但对于列表其他语言在这里。
我还看了sonar-dotnet。但它看起来与其他实现并不相似。
最后,老实说可能是我最后一次机会,我快速浏览了FxCop 自定义规则,但我不确定什么是正确的方法。
我想要做的只是一个基本的 c# 规则,可以像sonar 预定义的那样进行审查。
我的意思是,有不符合要求的准则和标准的解决方案。
我正在尝试将我的 Maven 项目与 SonarQube 集成,但是当我尝试运行时
mvn sonar:sonar -Dsonar.host.url=http://localhost:9000 -X
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
[DEBUG] 13:09:55.647 Create: /Users/gab/.sonar/cache/_tmp
[DEBUG] 13:09:55.650 Extract sonar-scanner-api-batch in temp...
[DEBUG] 13:09:55.657 Get bootstrap index...
[DEBUG] 13:09:55.658 Download: http://localhost:9000/batch/index
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 08:23 min
[INFO] Finished at: 2019-12-04T13:18:15+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project api-server: Unable to execute SonarQube: Fail to get bootstrap index from server: timeout: Read timed out -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal …Run Code Online (Sandbox Code Playgroud) sonarqube-scan ×10
sonarqube ×9
jenkins ×3
java ×2
sonar-runner ×2
c# ×1
groovy ×1
java-8 ×1
maven ×1
maven-3 ×1
typescript ×1