Travis、Maven 和 Sonarcloud 的失败github [英] Sonarcloud failure with Travis, Maven & github

查看:22
本文介绍了Travis、Maven 和 Sonarcloud 的失败github的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从事的一个项目(eclipse/scanning)使用 Travis 和 Sonar 进行持续集成和代码分析.

A project I work on (eclipse/scanning) uses Travis and Sonar for continuous integration and code analysis.

上周,我注意到构建在声纳步骤失败:

Last week, I noticed that builds were failing at the sonar step with:

ERROR: Error during SonarQube Scanner execution
org.sonar.squidbridge.api.AnalysisException: Please provide compiled classes of your project with sonar.java.binaries property

经过一些研究,我想我会通过更新 修复这个code>addons: 部分(sonarqubesonarcloud)并切换到使用 - mvn -q sonar:sonar 而不是 - .travis.yml 文件的 script: 部分中的 sonar-scanner.

After some research, I thought I'd fixed this by updating the addons: section (sonarqube to sonarcloud) and switching to using - mvn -q sonar:sonar rather than - sonar-scanner in the script: section of the .travis.yml file.

但现在,通过集成测试的外部拉取请求(来自分叉)在声纳步骤由于不同的原因而失败:

Now though, external pull requests (from forks) which make it past the integration tests are failing for a different reason at the sonar step:

$ mvn -q sonar:sonar
...
[ERROR] SonarQube server [http://localhost:9000] can not be reached

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project org.eclipse.scanning: Unable to execute SonarQube: Fail to get bootstrap index from server: Failed to connect to localhost/127.0.0.1:9000: Connection refused (Connection refused) -> [Help 1]

这似乎与日志中的早期差异有关:

This appears to be related to earlier differences in the log:

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#Pull-Requests-and-Security-Restrictions

还有一个完全缺失的 SonarCloud 插件部分.

and an entirely missing SonarCloud addon section.

要查看差异,请比较 失败的构建 #625(其中是来自分叉仓库的拉取请求)与 成功构建 #628 (这是来自 repo 的拉取请求).

To see the difference, compare the failed build #625 (which was a pull request from a forked repo) with the successful build #628 (which was a pull request from within the repo).

大约一个月前,外部拉取工作没有问题,例如 build #536 已通过,已正确运行 Setting environment variables from repository settingsSonarCloud addonsonar-scanner.

Around a month ago, external pulls work without issue, for instance build #536 passed, having run Setting environment variables from repository settings, SonarCloud addon and sonar-scanner correctly.

随后的构建,例如 构建 #538 已通过,但仅因为 sonar-scanner 跳过了分析并且 exited with 0 即使它们未能运行.

Subsequent builds however, such as build #538 passed, but only because sonar-scanner skipped analysis and exited with 0 even though they failed to run.

虽然我可能只是在外部拉取请求上禁用 Sonar,但如果我能修复我们的存储库,这样我们就可以对内部和外部拉取请求进行集成测试和代码分析,所以

While I could probably just disable Sonar on external pull requests, it would be nice if I could fix our repository so we got both integration tests and code analysis on both internal and external pull requests, so

  • 我原来的修复是正确的吗?
    • 如果是这样,我如何让它同时处理内部和外部拉取请求?
    • 如果没有,我应该如何解决原来的问题?

    注意,这个问题已被 How do I get Sonarcloud to run on pull requests from forks with Travis, Maven &github 专注于根本问题,而不是试图解决一些症状.

    Note, this question has been superceded by How do I get Sonarcloud to run on pull requests from forks with Travis, Maven & github which is focussed on the underlying problem rather than trying to fix some of the symptoms.

    推荐答案

    您的 PR 分析正在尝试(但失败)使用默认服务器:localhost:9000.

    Your PR analysis is attempting (and failing) to use the default server: localhost:9000.

    在另一种情况下,您会 更新 settings.xml 以指定位置,但由于您使用的是 Travis,因此您将在命令行中传递它:mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io

    In another circumstance, you would update settings.xml to specify the location but since you're using Travis, you'll pass it on the command line instead: mvn sonar:sonar -Dsonar.host.url=https://sonarcloud.io

    顺便说一句,这在您的常规 Travis 构建中有效,因为 Travis 的 SonarQube 集成专门是 Travis-SonarCloud 集成,因此服务器会自动填充.

    BTW, this is working in your normal Travis build because the SonarQube integration for Travis is specifically a Travis-SonarCloud integration, so server is filled in automatically.

    这篇关于Travis、Maven 和 Sonarcloud 的失败github的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆