代码之家  ›  专栏  ›  技术社区  ›  Xelian

如何配置SonarCloud

  •  10
  • Xelian  · 技术社区  · 8 年前

    我有一个java项目,我想将其与SonarCloud集成,我遵循官方步骤:

    使用SonarQube扫描仪检查代码#

    1. 加密此令牌travis Encrypt abcdef0123456789或在存储库设置中定义SONAR\u令牌
    2. 找到哪个声纳云。您希望推动项目并获取其密钥的io组织
    3. 创建声纳项目。项目的属性文件(请参阅文档)。然后将以下行添加到。特拉维斯。yml文件 要触发分析:

    加上我的特拉维斯。yml文件

     addons:
      sonarcloud:
        organization: "xelian-github"
        token:
          secure: ${SONAR_TOKEN}
        branches:
          - master
    script:
      # other script steps might be done before running the actual analysis
      - sonar-scanner
    

    enter image description here enter image description here

    但是当我开始travis构建时,我有以下错误:

    Setting environment variables from repository settings
    $ export SONAR_TOKEN=[secure]
    
     ....
    ERROR: Error during SonarQube Scanner execution
    ERROR: You're only authorized to execute a local (preview) SonarQube analysis without pushing the results to the SonarQube server. Please contact your SonarQube administrator.
    ERROR: 
    ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
    

    在我看来,travis没有权限将结果上传到SonarCloud。是令牌或某些声纳配置中的问题。

    2 回复  |  直到 8 年前
        1
  •  10
  •   slartidan    4 年前

    在SonarCloud上配置项目的官方入口点是 "Get Started" page :

    • 不需要 创建 sonar-project.properties

    • 你甚至可以找到一个指向 sample Maven project 这是在SonarCloud上分析的

        2
  •  0
  •   Xelian    8 年前

    声纳项目。属性

    # Required metadata
    sonar.projectKey=java-sonar-runner-simple:master
    sonar.projectName=Rss-service
    sonar.projectVersion=1.0
    
    # Comma-separated paths to directories with sources (required)
    sonar.sources=/microservice-application/rss-reader-service/src/main/java
    sonar.java.binaries=/microservice-application/rss-reader-service/target/classes
    
    # Language
    sonar.language=java
    
    # Encoding of the source files
    sonar.sourceEncoding=UTF-8
    

    在特拉维斯。yml I添加:

      # other script steps might be done before running the actual analysis
      - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar
    

    编辑 :