简体   繁体   English

Jenkins和SonarQube Scanner配置可脱机工作

[英]Jenkins and SonarQube Scanner configuration to work offline

I have the following situation: 我有以下情况:

Server Configuration: Jenkins ver. 服务器配置:Jenkins版本。 2.7.1, SonarQube Plugin 2.4.4 2.7.1,SonarQube插件2.4.4

My jobs are using SonarQube to check some quality measures. 我的工作正在使用SonarQube检查一些质量措施。 SonarQube Server is well configured in Jenkins and it was working well. SonarQube Server在Jenkins中配置良好,并且运行良好。

Till now I used SonarQube Scanner as a post build step, but now it is deprecated to do so. 到目前为止,我已将SonarQube Scanner用作构建后的步骤,但现在不建议这样做。

Then I change this to build step and ... 然后我将其更改为构建步骤并...

... after configuring SonarQube Scanner build step ...在配置SonarQube Scanner构建步骤之后

SonarCube Scanner Configuration SonarCube扫描仪配置

, I started job build, then I got: ,我开始建立工作,然后得到:

Skipping installation of https://repo1.maven.org/maven2/org/sonarsource/scanner/cli/sonar-scanner-cli/2.6.1/sonar-scanner-cli-2.6.1.zip to /.../.jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonar_Runner: java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.0 403 Forbidden"
------------------------------------------------------------------------
SONAR ANALYSIS FAILED
------------------------------------------------------------------------
FATAL: SonarQube Scanner executable was not found for Sonar Runner
Build step 'Execute SonarQube Scanner' marked build as failure

OK. 好。 That is true. 那是真实的。 It is not allowed to download anything from Internet direct to the Build Server. 不允许直接从Internet下载任何内容到Build Server。

On the page Analyzing with SonarQube Scanner there is nothing about this kind of automatic download made in the background and how to configure it. 在“ 使用SonarQube扫描仪进行分析 ”页面上没有关于在后台进行的这种自动下载以及如何进行配置的任何信息。

Here are all SonarCube options I see in Jenkins: 这是我在詹金斯中看到的所有SonarCube选项:

    SonarQube servers

    Environment variables
    SonarQube installations

    Name
    Server URL
    Server version
    Server authentication token
    SonarQube account login
    SonarQube account password
    Version of sonar-maven-plugin
    Additional arguments
    Additional analysis properties
    Database URL
    Database login
    Database password

    Skip if triggered by SCM Changes
    Skip if triggered by the build of a dependency
    Skip if environment variable is defined and set to true

I tried to set proxy as JAVA_OPTS or as environment variable, but it does not help, and anyhow I would not be very happy about that. 我试图将proxy设置为JAVA_OPTS或环境变量,但这无济于事,无论如何我对此并不满意。

Had someone found a way to use SonarQube Scanner offline? 有人找到了一种离线使用SonarQube Scanner的方法吗?

Remark: Setting up normal maven build step with sonar:sonar is not very comfortable, as every job shall be manually configured and shall explicitly call SonarQube Server (including complete parameterization). 备注:使用sonar:sonar设置正常的maven构建步骤不是很舒服,因为每个作业都必须手动配置,并且应显式调用SonarQube Server(包括完整的参数化)。

To your question: You can download SonarQube Scanner manually, make it available to Jenkins by dropping it on your Jenkins server/slaves, and in Global configuration ( Jenkins > Manage Jenkins > Configure System ) configure the path to it. 关于您的问题:您可以手动下载SonarQube Scanner,将其放到Jenkins服务器/从属服务器上,使其对Jenkins可用,然后在全局配置( Jenkins>管理Jenkins>配置系统 )中配置指向它的路径。 You'll see the input to configure the path once you uncheck "Install automatically". 取消选中“自动安装”后,您将看到用于配置路径的输入。

To your situation: If you were previously using the Post Build Action, then you're talking about Maven jobs. 针对您的情况:如果您以前使用过构建后操作,那么您在谈论的是Maven作业。 You say you don't want to use a standard mvn build step because of the configuration required in each job. 您说您不想使用标准的mvn构建步骤,因为每个作业都需要进行配置。 I would argue that switching your Maven jobs to use the SonarQube Scanner imposes a far higher configuration burden: now you must configure each analysis property manually, rather than having them read automatically from the pom. 我认为,将Maven作业切换为使用SonarQube扫描仪会带来更高的配置负担:现在,您必须手动配置每个分析属性,而不是让它们自动从pom读取。

Compared to that, 相比之下

  1. enabling the "Prepare SonarQube Scanner environment" Build Environment option and 启用“准备SonarQube扫描仪环境”构建环境选项,然后
  2. setting up a mvn build step that looks (literally!) like this sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN 设置一个看起来像这样的sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN的mvn构建步骤sonar:sonar -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN

seems like chicken feed. 好像是鸡饲料

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM