2017-03-20 14 views
2

私はSonarqubeインスタンスに接続された1つのマスター/ 1スレーブでJenkinsインスタンスを実行しています。私はパイプラインジョブを使用していますが、 "WaitForQualityGate"ステージが動作しないジェンキンスレーブ以外は正常に動作します。それはマスター上で正常に動作します。Jenkinsスレーブでエラーが発生しWaitForQualityGateが終了する

このエラーで私の仕事出口:

Java.lang.IllegalStateException: Unable to get SonarQube task id and/or server name. Please use the 'withSonarQubeEnv' wrapper to run your analysis. 

ステージ "withSonarQubeEnvは" の前に呼び出された場合であっても。

私の構成は次のとおりです。

  • ジェンキンスジョブは、「パイプラインスクリプト」を持ってチェックアウト私のソースコード+
  • 共有ライブラリは、暗黙のうちに
  • withSonarQubeEnvは「testCover」中に呼び出されロードされているパイプラインのスクリプトを

    :とwaitForQualityGateは "testQualityGate"

ジェンキンスジョブパイプラインスクリプト中に呼び出されます

node(){ 
    checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'jenkinsfile'], [$class: 'IgnoreNotifyCommit'], [$class: 'WipeWorkspace']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'credential', url: 'https://pipeline.git']]] 
    checkout changelog: true, scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'src'], [$class: 'WipeWorkspace']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'credential', url: 'https://sourcecode.git']]] 
    load 'jenkinsfile/Jenkinsfile' 
}() 

共有ライブラリ(testCover):

echo "Testing the coverage of the application" 
withSonarQubeEnv('sonarqube') { 
    withCredentials([string(credentialsId: 'sonarqube-token', variable: 'sonarqube_token')]) { 
     def scannerCmd = "sonar-scanner -e"; 
     scannerCmd += " -Dhttps.proxyHost=proxy.com"; 
     scannerCmd += " -Dhttps.proxyPort=8888"; 
     scannerCmd += " -Dhttp.proxyHost=proxy.com"; 
     scannerCmd += " -Dhttp.proxyPort=8888"; 
     scannerCmd += " -Dsonar.login=${env.sonarqube_token}"; 
     scannerCmd += " -Dsonar.password="; 
     sh "${scannerCmd}" 
    } 
} 

共有ライブラリ(testQualityGate):

sleep 10 
timeout(time: 3, unit: 'MINUTES') { 
    def qg = waitForQualityGate() 
    if (qg.status != 'OK') { 
     error "Pipeline aborted due to quality gate failure: ${qg.status}" 
    } 
} 

パイプラインの仕事:

{-> 
    node { 
     dir('src'){ 
      stage ('Init') { 
       initLib('node7') 
      } 

      stage ('Build app') { 
       withCredentials([[ 
        $class: 'UsernamePasswordMultiBinding', 
        credentialsId: 'npm-server', 
        usernameVariable: 'REG', 
        passwordVariable: 'TOKEN' 
       ]]) { 
        sh "echo '\n//${env.REG}/:_authToken=${env.TOKEN}' >> .npmrc" 
        buildApp() 
       } 
      } 

      stage ('Test/Lint') { 
       testApp() 
      } 

      stage ('Cover/static analysis') { 
       testCover() 
      } 

      stage ('Quality Gate') { 
       testQualityGate() 
      } 

      stage ('Flowdock notification') { 
       notifyFlowdock() 
      } 
     } 
    } 
} 

EDIT:深いを調査した後、私が見つけましたnodeステートメントへの2回の呼び出しから問題が発生する可能性があります。 (私のパイプラインスクリプト(仕事)で1、私のパイプラインファイルで1)。残念ながら、それは私の問題を解決していません=/ EDIT 2:私は、 "作業ディレクトリ:"と "ANALYSIS SUCCESSFULL"という行が私のビルドログに存在することを確認しました。 ".sonar"フォルダ(task-report.txtがどこにあるか)。したがって、基本的にはマスターノードでは動作していますが、スレーブでは同じ出力を持っていても同じです。/

+0

私たちは、このマスター/スレーブ問題を調査しているが、今の私は再現することができませんでしだ。グループのディスカッションに従ってください:https://groups.google.com/forum/#!msg/sonarqube/z_K_wz_8Vw8/-JJ0S-7ECAAJ –

答えて

2

実際に問題が発見されたジェンキンのソナープラグイン。ここでは、パッチが提供されるヘルプのためのhttps://repox.sonarsource.com/sonarsource-public-builds/org/jenkins-ci/plugins/sonar/2.6.1.1212/sonar-2.6.1.1212.hpi

おかげで、Googleのグループ(https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/sonarqube/z_K_wz_8Vw8)内のすべての人です。)

+0

この新しいプラグインが動作することを確認するには、ここをクリックしてください。私は古いものをアンインストールし、このアップデートをインストールしました。そして、私のパイプラインはwaitForQualityGate()でハングしません。 –

関連する問題