2017-01-16 90 views
0

私は同様の質問で利用可能な回答のほとんどを読んだが、私の質問に答えることはできません。JenkinsのJacocoコードカバレッジ0%カバレッジを表示

ポンポンファイル内の私のプロフィールは次のようになります。

  <plugins> 
       <plugin> 
        <groupId>org.jacoco</groupId> 
        <artifactId>jacoco-maven-plugin</artifactId> 
        <version>0.7.7.201606060606</version> 
        <executions> 
         <!-- Prepares the property pointing to the JaCoCo runtime agent which 
          is passed as VM argument when Maven the Surefire plugin is executed. --> 
         <execution> 
          <id>pre-unit-test</id> 
          <goals> 
           <goal>prepare-agent</goal> 
          </goals> 
          <configuration> 
           <!-- Sets the path to the file which contains the execution data. --> 
           <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile> 
           <!-- Sets the name of the property containing the settings for JaCoCo 
            runtime agent. --> 
           <propertyName>surefireArgLine</propertyName> 
          </configuration> 
         </execution> 
         <!-- Ensures that the code coverage report for unit tests is created 
          after unit tests have been run. --> 
         <execution> 
          <id>post-unit-test</id> 
          <phase>test</phase> 
          <goals> 
           <goal>report</goal> 
          </goals> 
          <configuration> 
           <!-- Sets the path to the file which contains the execution data. --> 
           <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile> 
           <!-- Sets the output directory for the code coverage report. --> 
           <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <version>2.19.1</version> 
        <configuration> 
         <skip>true</skip> 
        </configuration> 
        <executions> 
         <execution> 
          <id>surefire-unit-tests</id> 
          <phase>test</phase> 
          <goals> 
           <goal>test</goal> 
          </goals> 
          <configuration> 
           <!-- Sets the VM argument line used when unit tests are run. --> 
           <argLine>${surefireArgLine}</argLine> 
           <!-- Skips unit tests if the value of skip.unit.tests property is 
            true --> 
           <skipTests>${skip.unit.tests}</skipTests> 
           <!-- Excludes integration tests when unit tests are run. --> 
           <skip>false</skip> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-failsafe-plugin</artifactId> 
        <version>2.19.1</version> 
        <executions> 
         <!-- Ensures that both integration-test and verify goals of the Failsafe 
          Maven plugin are executed. --> 
         <execution> 
          <id>integration-tests</id> 
          <goals> 
           <goal>integration-test</goal> 
           <goal>verify</goal> 
          </goals> 
          <configuration> 
           <!-- Sets the VM argument line used when integration tests are run. --> 
           <argLine>${failsafeArgLine}</argLine> 
           <!-- Skips integration tests if the value of skip.integration.tests 
            property is true --> 
           <skipTests>${skip.integration.tests}</skipTests> 
          </configuration> 
         </execution> 
        </executions> 
       </plugin> 
      </plugins> 

私はMavenのゴールclean install -P test-coverage

と私のジェンキンスジョブを実行すると、私は私のジェンキンスでこれを参照してください。ログ:

`[JaCoCo plugin] Collecting JaCoCo coverage data... 
[JaCoCo plugin] **/target/coverage-reports/jacoco-ut.exec;**/target/classes;**/src/main/java; locations are configured 
[JaCoCo plugin] Number of found exec files for pattern **/target/coverage-reports/jacoco-ut.exec: 0 
[JaCoCo plugin] Saving matched execfiles: 
[JaCoCo plugin] Saving matched class directories for class-pattern: **/target/classes: 
[JaCoCo plugin] Saving matched source directories for source-pattern: **/src/main/java: 
[JaCoCo plugin] Loading inclusions files.. 
[JaCoCo plugin] inclusions: [] 
[JaCoCo plugin] exclusions: [] 
[JaCoCo plugin] Thresholds: JacocoHealthReportThresholds [minClass=0, maxClass=0, minMethod=0, maxMethod=0, minLine=0, maxLine=0, minBranch=0, maxBranch=0, minInstruction=0, maxInstruction=0, minComplexity=0, maxComplexity=0] 
[JaCoCo plugin] Publishing the results.. 
[JaCoCo plugin] Loading packages.. 
[JaCoCo plugin] Done. 
[JaCoCo plugin] Overall coverage: class: 0, method: 0, line: 0, branch: 0, instruction: 0` 

これを私のジェンキンスのJacocoの設定がどのようになっているのでしょうか。

enter image description here

+1

Jenkinsログに「Pattern/found/coverage-reports/jacoco-ut.exec:0」という行が見つかりました。そのようなファイルは、この行の上にビルドログを表示する必要があります。 – Godin

+0

@Godinただそこで成功しました。実際には、ビルドディレクトリとジェンキンスジョブのワークスペースが異なっていました。 – ASR

+0

また、execファイルの場所を '**/jacoco.exec'に変更した方が、プラグインの提案に従う方が良いでしょう。 – ASR

答えて

0

私の場合、execファイルを取得できませんでした。

私のビルドディレクトリがJenkinsジョブのWORKSPACEと異なるためです。ビルドディレクトリをワークスペースに変更すると、魔法が起こりました。

0

私の場合は、jacocoant 0.6を使用していましたが、jenkinsのjaCoCoプラグインは2.2.0でした。 jaCoCoプラグインのgithubのページから :

バージョン2.0.0と高い任意のJaCoCo 0.7.5以降、プロジェクトはまだJaCoCo 0.7.4を使用している場合、プラグインが表示されません任意のコード・カバレッジ番号を使用する必要がありますもっと!この場合、コードベースでjacocoを更新するまでバージョン1.0.19を使用してください。私の場合は https://github.com/jenkinsci/jacoco-plugin

0

、Jacocoプラグインは1.0.19ですが、私はそれは互換性がありませんJacoco-mavenの-プラグイン0.7.9を、使用しています。

したがって、Jacoco-maven-pluginを0.7.4.xに変更した後。 Jenkinsのログに正しい内容が含まれています

関連する問題