2017-05-20 3 views
0

ゲンキンと品質ゲートの使用方法を説明しているthis official postdocumentationを読んでいます。Sonarqubeの高品質ゲートを使用してゲンキンにウェブフックをトリガーする方法

私の目標は、質の高いゲートが渡された場合、ジェンキンのビルドをトリガーすることです。

投稿によると、私はsonarqubeをインストールし、コードスニペットを使用するだけです。

これは、ジェンキンスさんは、手動でビルドをトリガした後、ログです:

> 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 

私はジェンキンスさんにこのような構成ソナージェンキンスプラグインを設定している:

image

を私もインストールされていますSonarqube Quality Gates Plugin in jenkins:(ただし、著者によるとQuality Gates Pluginは廃止予定です)

image

これが私の仕事の設定で私のパイプラインのGroovyスクリプトです:

node { 
    stage('SCM') { 
    git credentialsId: 'a011099a-e3f6-4d67-9e99-8887b186699d', url: 'ssh://[email protected]/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やジェンキンスを使用して、どのような方法を探していますアプリケーションがデプロイされているかどうかを判断する。

答えて

1

これは明らかに、このジョブに定義されて

SonarQubeのインストール(マイSonarQubeサーバー)が設定済みのインストールと一致していないと言います。

instructionsは言う:

管理者としてジェンキンスさんにあなたのSonarQubeサーバ(複数可)

  • ログインを設定して、ジェンキンス>設定システム管理するために行く:まで
  • スクロールSonarQube設定セクションで、Add SonarQubeをクリックして、プロンプトが表示された値を追加します。あなたは、ドキュメントに自分自身を参照してきた一方で

が、まだあなたのいずれかを行うか、インストールのために別の名前を使用していないようです。

疑いで、あなたの投稿を編集してくださいとジェンキンスを管理SonarQube構成からスクリーンショットを追加します。

+0

のために、私は私の設定のいくつかのスクリーンショットを追加していませんでした。私はこの勧告に従って設定しようとしています。コードスニペットジェネレータでhttp://stackoverflow.com/questions/38124171/execute-sonarqube-scanner-within-jenkins-2-pipelineを参照してください。 – BigDong

1

あなたはSonarScannerと品質ゲートプラグイン

をインストールする必要がありますと、以下のようにSonarServer説明責任>セキュリティから、あなたがそれを生成する必要がプロジェクトのキーを設定を入れて、ジェンキンスにセキュリティキーを置きますSonarqubeセクションの構成は

enter image description hereがjpg

はポストビルドアクションにおける品質ゲートのプラグインを含めるenter image description here

あなたがあなたのビルドを作成しようとしているQualitygateセクションの属性を設定する必要がありSonarserverページで

enter image description here

+0

どのようなプロジェクトを使用していますか? _freestyle_?どのバージョンの高品質なゲートプラグインを使用していますか、どのバージョンのsonarqubeを使用していますか?あなたの設定を共有してくれてありがとう。私は – BigDong

+0

のスクリーンショットを追加しました。そのフリースタイルのプロジェクトはJenkinsファイルを使用していません。そのPOC品質ゲートバージョンは、私が昨日作成した最新のものです –

+0

あなたはこのプラグインを受け取りましたか? :https://github.com/jenkinsci/sonar-quality-gates-plugin/commit/ae995369b3dd94ddc093b1d035928ac707cc7a8d – BigDong

関連する問題