标签: sonarqube-scan

pluginRepository的Gradle配置

我试图通过Sonar的静态代码分析来获得一个简单的Gradle项目(由eclipse自动创建的项目),以便在我们的持续集成上运行.我们的CI服务器位于代理服务器后面,我必须通过内部Nexus服务器访问Gradle插件存储库.

正如所描述的userguide我已经添加了以下我settings.gradle

pluginRepositories {
  maven {
    url 'http://link.to.my.nexus'
  }
  gradlePluginPortal()
}

rootProject.name = 'GradleTestProject'
Run Code Online (Sandbox Code Playgroud)

我的build.gradle看起来像这样:

plugins {
  id "org.sonarqube" version "2.0.1"
}

apply plugin: 'java'

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.21'

    testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)

当我在Jenkins上运行它时,我收到以下错误消息:

FAILURE: Build failed with an exception.

* Where:
Settings file '/opt/hudson/jobs/GradleTestProject/workspace/settings.gradle' line: 1

* What went wrong:
A problem occurred evaluating settings 'workspace'.
> Could not find method pluginRepositories() for arguments [settings_20tc2o9xuj82hi1fvpe4wvcvt$_run_closure1@52b56c40] on settings 'workspace'.
Run Code Online (Sandbox Code Playgroud)

我查看了网络上的其他示例.他们都像我描述的那样做.

顺便说一句:我正在使用Gradle 2.12

plugins gradle jenkins sonarqube sonarqube-scan

8
推荐指数
1
解决办法
4134
查看次数

使用SonarQube Scanner for MSBuild控制模块名称

我试图通过将以下xml片段添加到我的csproj文件来更改C#项目的模块名称:

<ItemGroup> 
    <SonarQubeSetting Include="sonar.projectName">
        <Value>Core.XY</Value>
    </SonarQubeSetting>
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)

这按照我的预期方式工作(相应地设置SonarQube中的模块名称).

问题:这是支持还是只是意外工作?如果我不得不担心它会随着下一次升级而改变,我真的不想使用这种行为.

生成的sonar-project.properties文件包含以下条目:

B6CCB06F-640A-428E-8A4E-4BBBAD881400.sonar.projectName=XY
...
B6CCB06F-640A-428E-8A4E-4BBBAD881400.sonar.projectName=Core.XY
Run Code Online (Sandbox Code Playgroud)

这可能意味着我的配置或多或少地偶然起作用.


更新: 以下解释了为什么我要更改某些项目的模块名称:我有几个项目的解决方案,例如

Core.sln
- Lib.csproj
- Tools.csproj
Service.sln
- Lib.csproj
- ...
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我最终在SonarQube中有两个"Lib"模块,除非我有一种覆盖模块名称的方法.我当然可以重命名项目,但我宁愿能够简单地告诉SonarQube使用哪个模块名称.

如果Sonar Scanner使用程序集名称而不是项目名称,我也会非常高兴.

sonarqube sonarqube-msbuild-runner sonarqube-scan

8
推荐指数
1
解决办法
410
查看次数

声纳怎么样:声纳工作?

我们想在项目中使用SonarQube和一些CI工具.Sonar Server url在主pom.xml中配置.

项目中有几个团队成员.那么当一个团队成员执行声纳时会发生什么:本地声纳与他的本地变化,然后另一个团队成员执行声纳:声纳与他的本地更改,然后有人执行声纳:来自CI工具的声纳(它配置为分析Git中的源代码)库)?

SonarQube会显示相关团队成员本地更改的问题吗?如果团队成员本地源代码和Git存储库中的源代码之间存在差异怎么办?

java bamboo maven sonarqube sonarqube-scan

8
推荐指数
1
解决办法
2951
查看次数

在Jenkins声明性管道中使用waitForQualityGate

Jenkins 2.50中声明性管道中的以下SonarQube(6.3)分析阶段在控制台日志中出现此错误失败:http://pastebin.com/t2ja23vC.进一步来说:

此作业(SonarGate)中定义的SonarQube安装与任何已配置的安装都不匹配.可配置的安装数量:1.

更新:在Jenkins设置中将"SonarQube"更改为"SonarGate"后(在SonarQube服务器下,所以它将与Jenkins文件匹配),我得到一个不同的错误:http://pastebin.com/HZZ6fY6V

java.lang.IllegalStateException:无法获取SonarQube任务ID和/或服务器名称.请使用'withSonarQubeEnv'包装器来运行分析.


该阶段是对SonarQube文档中示例的修改:https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzinginaJenkinspipeline

stage ("SonarQube analysis") {
     steps {
        script {
           STAGE_NAME = "SonarQube analysis"

           if (BRANCH_NAME == "develop") {
              echo "In 'develop' branch, don't analyze."
           }
           else { // this is a PR build, run sonar analysis
              withSonarQubeEnv("SonarGate") {
                 sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner"   
              }
           }
        }
     }
  }

  stage ("SonarQube Gatekeeper") {
     steps {
        script {
           STAGE_NAME = "SonarQube Gatekeeper"

           if (BRANCH_NAME == "develop") {
              echo "In 'develop' branch, …
Run Code Online (Sandbox Code Playgroud)

jenkins jenkins-plugins sonarqube jenkins-pipeline sonarqube-scan

8
推荐指数
2
解决办法
2万
查看次数

SonarQube - 无法使用UTF-16编码分析xml和xsd文件

我正在使用sonarqube(版本5.6.7)和声纳扫描仪(版本3.0.3.778)来分析一些文档.在这些文档中,还有.xml.xsd文件,其中包含了UTF-16.

当我sonar-scanner从命令行启动命令时,使用此配置

#----- Default SonarQube server
sonar.host.url=http://localhost:9000

#----- Default source code encoding
sonar.sourceEncoding=UTF-16

# must be unique in a given SonarQube instance
sonar.projectKey=my:project
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=My project 1
sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional …
Run Code Online (Sandbox Code Playgroud)

xml xsd utf-16 sonarqube sonarqube-scan

8
推荐指数
0
解决办法
520
查看次数

SonarQube:如何在Kotlin代码中禁止显示警告

我正在将SQ 7.3-alpha1与sonar-kotlin-plugin-1.0.1.965.jar一起使用。但是,我无法在Spring数据存储库的Kotlin代码内停用特殊警告,该方法需要在方法名称中添加“ _”。我尝试了//NOSONAR@Suppress("kotlin:S100")@SuppressWarnings("kotlin:S100")。任何提示表示赞赏。

kotlin sonarqube sonarqube-scan

8
推荐指数
1
解决办法
540
查看次数

声纳中的coverage_exclusions 与排除之间有什么区别?

声纳中的coverage_exclusionsvs 有什么区别exclusions?例子:

"sonar": {
    "exclusions": "gulpfile.js, ...",
    "coverage_exclusions": "gulpfile.js, ..., server/models/*.js",
    "quality_gate": "...",
    "server_id": "SONAR-main"
  },
Run Code Online (Sandbox Code Playgroud)

javascript node.js sonarqube sonarqube-scan

8
推荐指数
1
解决办法
7046
查看次数

Sonarqube 笑话覆盖率报告在预期的 XML 格式上失败

我使用 jest-sonar-reporter 进行覆盖,如下所示:

包.json

{
    "name": "app",
    "version": "1.0.0",
    "description": "The task runner packages for Gulp",
    "main": "gulpfile.js",
    "scripts": {
        ...
        "test": "jest --coverage",
        ...
    },
"devDependencies": {
   ...
    "jest": "26.0.1",
    "jest-sonar-reporter": "2.0.0",
    ...
    },
    "jest": {
        ...
        "collectCoverage": true,
        "testResultsProcessor": "jest-sonar-reporter"
    },
    "jest-junit": {
        "suiteName": "jest tests",
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

我在npm run test后生成了 test-report.xml 文件,如下所示:

测试报告.xml

<?xml version="1.0" encoding="UTF-8"?>
<testExecutions version="1">
  <file path="<path to>\AreaList.test.jsx">
    <testCase name="Description 1 " duration="6"/>
  </file>
  <file path="<path to>\selectors.search.test.js">
    <testCase name="Description 2 " duration="2"/> …
Run Code Online (Sandbox Code Playgroud)

javascript sonar-runner sonarqube jestjs sonarqube-scan

8
推荐指数
0
解决办法
1万
查看次数

如何在Ionic 2项目上运行声纳扫描仪

我们已经将我们的前端项目迁移ionic/es6/angular到了ionic2/typescript/angular2.一切都很好,除了我们不知道如何运行声纳报告项目.

以前我们使用gulp和run gulp sonar命令生成声纳报告(在本地声纳服务器上).

我们不会在新的ionic2项目中使用gulp,并想知道如何在新项目中运行声纳扫描仪.

注意

  1. 我们在声纳服务器上安装了typescript插件.
  2. 我们sonar-project.properties在项目rood目录中添加了文件

问题是如何运行它

谢谢...

typescript sonarqube ionic2 sonarqube-scan angular

7
推荐指数
1
解决办法
2237
查看次数

Sonarqube PLSQL自定义规则,用于在SQL脚本文件中检测正确的SQL终止符分号

我正在使用Jenkins和SONARQUBE PL/SQL插件进行Oracle SQL代码分析,我需要使用XPATH创建自定义规则,以便对通过Jenkins进行部署的SQL Script文件进行质量分析.

我正在尝试创建一个自定义规则,检测在任何SQL命令结束时是否缺少分号(";").SQL终止("分号")对于使用SQLPLUS部署SQL脚本非常重要.

代码示例

 insert into table_name values('wait','for','completion'); -- compliant with script 
 insert into table_name values('somename','for','good'); -- compliant with script 
 **insert into table_name values('someplace','for','game')** -- non compliant as semicolon missing
 insert into table_name values('something','for','change'); -- compliant with script 
 delete from table_name ; -- compliant with script 
 delete from table_name ; -- compliant with script 
 update table_name set name='james' where id='22';
Run Code Online (Sandbox Code Playgroud)

有一个缺少分号的插入查询,因此sonarqube应该检测到这个并且无法使jenkins构建失败或者无法进行SONAR质量测试.

请帮助创建PLSQL自定义规则,以便通过分号检测正确的SQL终止.

xpath的例子是: / COMPILATION_UNIT/ANY_DML_EXPRESSION/following-sibling :: SEMICOLON - 这样的东西

plsql jenkins sonarqube sonarqube-scan sonar-plugin

7
推荐指数
1
解决办法
485
查看次数