2017-01-16 13 views
0

비슷한 질문에 대해서는 답변을 대부분 읽었지만 내 질문에는 답할 수 없습니다.Jacquo 코드 커버리지는 Jenkins에서 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> 

내 젠킨스이 참조 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/** target/coverage-reports/jacoco-ut.exec : 0' 행에''발견 된 exec 파일 수 '가 있음을 알 수 있습니다. 이 파일은이 줄 위의 빌드 로그를 살펴 봐야합니다. – 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 - 받는다는 - 플러그인 0.7.9를 사용하고 있습니다.

그래서 Jacoco-maven-plugin을 0.7.4.x로 변경하십시오. Jenkins에 대한 정확한 적용 범위를 얻었습니다.