Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Sonarqube中的质量门触发jenkins的webhook_Jenkins_Sonarqube_Sonar Runner - Fatal编程技术网

如何使用Sonarqube中的质量门触发jenkins的webhook

如何使用Sonarqube中的质量门触发jenkins的webhook,jenkins,sonarqube,sonar-runner,Jenkins,Sonarqube,Sonar Runner,我正在阅读这篇文章,这篇文章解释了jenkins应该如何使用质量关卡 我的目标是,如果质量关卡通过,在詹金斯启动一个构建 根据帖子,我只需要安装sonarqube并使用代码片段 这是手动触发生成后的jenkins日志: > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeou

我正在阅读这篇文章,这篇文章解释了jenkins应该如何使用质量关卡

我的目标是,如果质量关卡通过,在詹金斯启动一个构建

根据帖子,我只需要安装sonarqube并使用代码片段

这是手动触发生成后的jenkins日志:

 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 8cddf9af39adbada9366efd3d707d8056c27cd8d (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 8cddf9af39adbada9366efd3d707d8056c27cd8d
 > git branch -a -v --no-abbrev # timeout=10
 > git branch -D master # timeout=10
 > git checkout -b master 8cddf9af39adbada9366efd3d707d8056c27cd8d
 > git rev-list 8cddf9af39adbada9366efd3d707d8056c27cd8d # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (build & SonarQube Scan)
[Pipeline] wrap
[Pipeline] // wrap
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
hudson.remoting.ProxyException: hudson.AbortException: SonarQube installation defined in this job (My SonarQube Server) does not match any configured installation. Number of installations that can be configured: 1.
If you want to reassign a lot of jobs to a different SonarQube installation see http://docs.sonarqube.org/display/PLUG/Reassign+Jobs+to+Another+SonarQube+Instance
    at hudson.plugins.sonar.SonarInstallation.checkValid(SonarInstallation.java:170)
    at hudson.plugins.sonar.SonarBuildWrapper.setUp(SonarBuildWrapper.java:81)
    at org.jenkinsci.plugins.workflow.steps.CoreWrapperStep$Execution.start(CoreWrapperStep.java:80)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:184)
Caused: hudson.remoting.ProxyException: org.codehaus.groovy.runtime.InvokerInvocationException: hudson.AbortException: SonarQube installation defined in this job (My SonarQube Server) does not match any configured installation. Number of installations that can be configured: 1.
If you want to reassign a lot of jobs to a different SonarQube installation see http://docs.sonarqube.org/display/PLUG/Reassign+Jobs+to+Another+SonarQube+Instance
    at org.jenkinsci.plugins.workflow.cps.CpsStepContext.replay(CpsStepContext.java:497)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:213)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:313)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:129)
    at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
    at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
    at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
    at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
    at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
Caused: hudson.remoting.ProxyException: java.lang.IllegalArgumentException: Failed to prepare withSonarQubeEnv step
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeDescribable(DSL.java:315)
    at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:129)
    at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
    at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
    at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
    at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
    at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
    at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
    at WorkflowScript.run(WorkflowScript:6)
    at ___cps.transform___(Native Method)
    at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
    at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
    at sun.reflect.GeneratedMethodAccessor499.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
    at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
    at com.cloudbees.groovy.cps.Next.step(Next.java:74)
    at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:30)
    at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
    at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:30)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:165)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:330)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:242)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:230)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Finished: FAILURE
我在jenkins配置中配置了Sonar jenkins插件,如下所示:

我还在jenkins中安装了Sonarqube质量门插件()(而不是质量门插件,根据作者的说法,质量门插件已被弃用)

这是我的作业配置中的管道groovy脚本:

node {
  stage('SCM') {
    git credentialsId: 'a011099a-e3f6-4d67-9e99-8887b186699d', url: 'ssh://git@module.domain.com/docs/styled.git'
  }
  stage('build & SonarQube Scan') {
    def sonarqubeScannerHome = tool name: 'domain', type: 'hudson.plugins.sonar.SonarRunnerInstallation'
    withSonarQubeEnv('My SonarQube Server') {
        sh "${sonarqubeScannerHome}/bin/sonar-scanner"
    } // SonarQube taskId is automatically attached to the pipeline context
  }
}

// No need to occupy a node
stage("Quality Gate") {
  timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
    def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
    if (qg.status != 'OK') {
      error "Pipeline aborted due to quality gate failure: ${qg.status}"
    }
  }
}
我真的在寻找任何方法,使用gitlab ci或jenkins利用质量门来决定是否部署应用程序。

它清楚地表明

此作业(我的SonarQube服务器)中定义的SonarQube安装与任何配置的安装不匹配

他们说:

配置SonarQube服务器

  • 以管理员身份登录Jenkins,进入管理Jenkins>配置系统:
  • 向下滚动至SonarQube配置部分,单击AddSonarQube,然后添加提示您输入的值
虽然您自己也在参考文档,但似乎您尚未完成安装或使用了不同的名称

如有疑问,请编辑您的帖子,并在Manage Jenkins中添加SonarQube配置的屏幕截图。

上面清楚地说

此作业(我的SonarQube服务器)中定义的SonarQube安装与任何配置的安装不匹配

他们说:

配置SonarQube服务器

  • 以管理员身份登录Jenkins,进入管理Jenkins>配置系统:
  • 向下滚动至SonarQube配置部分,单击AddSonarQube,然后添加提示您输入的值
虽然您自己也在参考文档,但似乎您尚未完成安装或使用了不同的名称


如有疑问,请编辑您的帖子,并在Manage Jenkins中添加SonarQube配置的屏幕截图。

您必须安装SonarScannerQuality gate插件

将配置放在下面,您必须从SonarServer帐户->安全中生成项目密钥,并将安全密钥放在Sonarqube中的Jenkins配置部分

jpg

在后期构建操作中包括质量门插件


在Sonarserver页面中,您已经在Qualitygate部分配置了属性,您正在尝试使您的构建失败

您必须安装SonarScannerQuality gate插件

将配置放在下面,您必须从SonarServer帐户->安全中生成项目密钥,并将安全密钥放在Sonarqube中的Jenkins配置部分

jpg

在后期构建操作中包括质量门插件


在Sonarserver页面中,您已经在Qualitygate部分配置了属性,您正在尝试使您的构建失败

我已经添加了一些配置的屏幕截图。我正在尝试使用代码段生成器根据此建议进行配置,希望看到一个工作示例!我添加了一些配置的屏幕截图。我正在尝试使用代码段生成器根据此建议进行配置,希望看到一个工作示例!你在使用什么样的项目?即兴说唱?您使用的是什么版本的quality gate插件,sonarqube的版本是什么?非常感谢分享您的配置。我已经添加了一些Mine的截图,它是一个自由式项目,没有使用Jenkins文件,它是一个POC质量门版本,我猜是最新的,因为我昨天刚刚创建了它,你有没有使用这个插件(另请参见我与作者的讨论:最新的sonar版本存在一些问题,请您将其降级到较低版本,并检查我是否已通过管道使用sonarqube服务器的名称
和Sonarqubeenv(“命名的\u用于\u sonarqube\u服务器”)解决了这些问题。)
。我正试图用gitlab ci做同样的事情,因为jenkins在我运行jest测试时崩溃了,但我认为这是不可能的。你在使用什么样的项目?自由式?你在使用什么版本的quality gate插件和什么版本的sonarqube?非常感谢分享你的配置。我添加了一些min的屏幕截图这是一个自由式的项目没有使用Jenkins文件,它的POC质量门版本是最新的,我猜我昨天刚刚创建的,你有没有使用这个插件(另请参见我与作者的讨论:最新的sonar版本存在一些问题,请您将其降级到较低版本,并检查我是否已通过管道使用sonarqube服务器的名称
和Sonarqubeenv(“命名的\u用于\u sonarqube\u服务器”)解决了这些问题。)
。我正试图用gitlab ci做同样的事情,因为jenkins在我运行jest测试时崩溃,但我认为这是不可能的。