Maven Golang版本未扫描Go

问题描述 投票:0回答:1

我们正在使用maven来构建Golang项目,因为我们是一家混合语言商店,而maven是当前的构建标准。

我们的第一个Go应用程序是为Vue项目提供服务的一组服务。

jenkins文件像这样调用mvn sonar:sonar:

    stage('Sonar') {
        steps {
            echo 'Building Sonar'
            withSonarQubeEnv('Sonar') {
                // requires SonarQube Scanner for Maven 3.2+
                withMaven(
                        maven: 'Maven 3.5.3',
                        globalMavenSettingsConfig: 'GlobalSettingsRepo',
                        jdk: 'Java 8 Oracle',
                        options: [
                                artifactsPublisher(disabled: true),
                                jacocoPublisher(disabled: true)]) {
                    sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar -U'
                }
            }
        }
    }

我已经将父pom和Go文件夹内的pom更新为包括:

<dependencies>
    <dependency>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>sonar-maven-plugin</artifactId>
        <version>3.4.0.905</version>
    </dependency>
    <dependency>
        <groupId>org.sonarsource.go</groupId>
        <artifactId>sonar-go-plugin</artifactId>
        <version>1.0.0.1404</version>
    </dependency>
</dependencies>

我也已将GOPATH硬编码到环境变量中的Go文件夹中。但是,当我运行构建时,声纳扫描仪仅扫描项目中的xml文件。如果我从命令行运行声纳扫描仪,它将同时分析Go代码和Vue代码。

有什么建议吗?

maven go sonarqube-scan
1个回答
0
投票

显然,声纳扫描器默认情况下将分析您的整个项目结构,并且需要显式排除项来跳过显然不应该分析的目录,例如node_modules。

Maven声纳插件希望您明确枚举源目录。我将以下行放在子pom.xml文件中,它按预期的方式工作。

Golang pom.xml:

<properties>
    <sonar.sources>src/go</sonar.sources>
</properties>

Vue pom.xml:

<properties>
    <sonar.sources>src/views,src/components,src/assets/js,src/assets/css</sonar.sources>
</properties>
© www.soinside.com 2019 - 2024. All rights reserved.