Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-73297

Report a warning when the delta cannot be computed because of multiple SCMs

      I installed this plugin, and i can get most of metric but changed files' coverage.

      i user Bitbucket server wth git client to clone sources codes, and Jenkins version is Jenkins 2.452.1.

      plugin version is 1.15.

      Below is changed files.

      And its Coverage of changed files is empty

          [JENKINS-73297] Report a warning when the delta cannot be computed because of multiple SCMs

          Ulli Hafner added a comment -

          Without more details I cannot help. What coverage delta do you expect in the example? What does the coverage plugin report in the log (https://[jenkins]/job/[jobname]/[buildnumber]/coverage/info/)?

          Ulli Hafner added a comment - Without more details I cannot help. What coverage delta do you expect in the example? What does the coverage plugin report in the log ( https://[jenkins]/job/[jobname]/[buildnumber]/coverage/info/)?

          Steven added a comment - - edited

          Thank you for your quick reply.

          i just want to get changed file's coverage based on changed files based on pull request.


          i use below code in pipeline
           

          discoverGitReferenceBuild() 
          recordCoverage(id: 'jacoco', name: 'JaCoCo Coverage',enabledForFailure: true,ignoreParsingErrors: true,qualityGates: [[baseline: 'MODIFIED_FILES_DELTA', criticality: 'FAILURE', integerThreshold: 80, metric: 'LINE', threshold: 80.0]],tools: [[parser: 'JACOCO']])		

          enabledForFailure: true, 
          ignoreParsingErrors: true, 
          qualityGates: [[baseline: 'MODIFIED_FILES_DELTA', criticality: 'FAILURE', integerThreshold: 80, metric: 'LINE', threshold: 80.0]], 
          tools: [[parser: 'JACOCO']])
           

          below are logs.

          Recording coverage results
          Creating parser for JaCoCo Coverage Reports
          Using default pattern '**/jacoco.xml' since user defined pattern is not set
          Searching for all files in '/var/jenkins_home/workspace/x-api' that match the pattern '**/jacoco.xml'
          Traversing of symbolic links: disabled
          -> found 1 file
          Successfully parsed file '/var/jenkins_home/workspace/x-api/target/site/jacoco/jacoco.xml'
          MODULE: 100.00% (1/1)
          PACKAGE: 21.43% (9/42)
          FILE: 6.81% (60/881)
          CLASS: 6.78% (62/915)
          METHOD: 4.02% (386/9592)
          LINE: 4.04% (725/17947)
          BRANCH: 0.45% (105/23112)
          INSTRUCTION: 2.15% (3812/177492)
          COMPLEXITY: 21154
          COMPLEXITY_MAXIMUM: 97
          COMPLEXITY_DENSITY: 21154/17947
          LOC: 17947
          Successfully processed file 'target/site/jacoco/jacoco.xml'
          Resolving source code files...
          Searching for source code files in '/var/jenkins_home/workspace/x-api/src/main/java'
          -> resolved absolute paths for all 881 source files
          Making paths of 881 source code files relative to workspace root...
          Obtaining result action of reference build
          Obtaining reference build from reference recorder
          -> Found 'x-api 2.8.0-SNAPSHOT'
          -> Using reference build 'x-api #1427'
          Calculating the code delta...
          -> Git delta calculator successfully created in working tree '/var/jenkins_home/workspace/x-api'
          -> Using commit '594b99a' as latest commit for build 'x-api #1429'
          -> Using commit '41002f4' as latest commit for build 'x-api 2.8.0-SNAPSHOT'
          -> Invoking Git delta calculator for determining the changes between commits '594b99a' and '41002f4'
          Preprocessing code changes...
          Successfully mapped SCM paths to coverage report paths
          Successfully verified that the coverage data matches with the code delta
          Obtaining code changes for files...
          Obtaining indirect coverage changes...
          Obtaining coverage delta for files...
          Calculating coverage deltas...
          Evaluating quality gates
          -> All quality gates have been passed
          -> Details for each quality gate:
             - [Modified files (difference to reference job) - Line Coverage]: ≪Not built≫ - (Actual value: n/a, Quality gate: 80.00)
          Executing source code painting...
          Painting 881 source files on agent
          -> finished painting successfully
          -> zipping sources from folder '/var/jenkins_home/workspace/x-api/jacoco' as '/var/jenkins_home/workspace/x-api/coverage-sources.zip'
          Copying painted sources from agent to build folder
          -> extracting...
          -> done
          Deleting source code files of build 2.8.0-SNAPSHOT
          Finished coverage processing - adding the action to the build... 

          Thanks

          Steven added a comment - - edited Thank you for your quick reply. i just want to get changed file's coverage based on changed files based on pull request. i use below code in pipeline   discoverGitReferenceBuild() recordCoverage(id: 'jacoco' , name: 'JaCoCo Coverage' ,enabledForFailure: true ,ignoreParsingErrors: true ,qualityGates: [[baseline: 'MODIFIED_FILES_DELTA' , criticality: 'FAILURE' , integerThreshold: 80, metric: 'LINE' , threshold: 80.0]],tools: [[parser: 'JACOCO' ]]) enabledForFailure: true,  ignoreParsingErrors: true,  qualityGates: [ [baseline: 'MODIFIED_FILES_DELTA', criticality: 'FAILURE', integerThreshold: 80, metric: 'LINE', threshold: 80.0] ],  tools: [ [parser: 'JACOCO'] ])   below are logs. Recording coverage results Creating parser for JaCoCo Coverage Reports Using default pattern '**/jacoco.xml' since user defined pattern is not set Searching for all files in '/ var /jenkins_home/workspace/x-api' that match the pattern '**/jacoco.xml' Traversing of symbolic links: disabled -> found 1 file Successfully parsed file '/ var /jenkins_home/workspace/x-api/target/site/jacoco/jacoco.xml' MODULE: 100.00% (1/1) PACKAGE: 21.43% (9/42) FILE: 6.81% (60/881) CLASS: 6.78% (62/915) METHOD: 4.02% (386/9592) LINE: 4.04% (725/17947) BRANCH: 0.45% (105/23112) INSTRUCTION: 2.15% (3812/177492) COMPLEXITY: 21154 COMPLEXITY_MAXIMUM: 97 COMPLEXITY_DENSITY: 21154/17947 LOC: 17947 Successfully processed file 'target/site/jacoco/jacoco.xml' Resolving source code files... Searching for source code files in '/ var /jenkins_home/workspace/x-api/src/main/java' -> resolved absolute paths for all 881 source files Making paths of 881 source code files relative to workspace root... Obtaining result action of reference build Obtaining reference build from reference recorder -> Found 'x-api 2.8.0-SNAPSHOT' -> Using reference build 'x-api #1427' Calculating the code delta... -> Git delta calculator successfully created in working tree '/ var /jenkins_home/workspace/x-api' -> Using commit '594b99a' as latest commit for build 'x-api #1429' -> Using commit '41002f4' as latest commit for build 'x-api 2.8.0-SNAPSHOT' -> Invoking Git delta calculator for determining the changes between commits '594b99a' and '41002f4' Preprocessing code changes... Successfully mapped SCM paths to coverage report paths Successfully verified that the coverage data matches with the code delta Obtaining code changes for files... Obtaining indirect coverage changes... Obtaining coverage delta for files... Calculating coverage deltas... Evaluating quality gates -> All quality gates have been passed -> Details for each quality gate:    - [Modified files (difference to reference job) - Line Coverage]: ≪Not built≫ - (Actual value: n/a, Quality gate: 80.00) Executing source code painting... Painting 881 source files on agent -> finished painting successfully -> zipping sources from folder '/ var /jenkins_home/workspace/x-api/jacoco' as '/ var /jenkins_home/workspace/x-api/coverage-sources.zip' Copying painted sources from agent to build folder -> extracting... -> done Deleting source code files of build 2.8.0-SNAPSHOT Finished coverage processing - adding the action to the build... Thanks

          Ulli Hafner added a comment -

          Somehow the diff is not computed. In my log I have:

          -> Invoking Git delta calculator for determining the changes between commits '1f22604' and '4854b02'
          -> Start scanning for differences between commits...
          -> 1 files contain changes
          -> Creating the Git diff file
          -> Git code delta successfully calculated
          

          The message "Start scanning for differences between commits" is totally missing, even if there are no diffs it should be shown.

          Do you have exceptions from my plugins in the log? Are you using multiple Git repositories in the build?

          Ulli Hafner added a comment - Somehow the diff is not computed. In my log I have: -> Invoking Git delta calculator for determining the changes between commits '1f22604' and '4854b02' -> Start scanning for differences between commits... -> 1 files contain changes -> Creating the Git diff file -> Git code delta successfully calculated The message "Start scanning for differences between commits" is totally missing, even if there are no diffs it should be shown. Do you have exceptions from my plugins in the log? Are you using multiple Git repositories in the build?

          Steven added a comment - - edited

          Yes, for this job, has just one Git repository, but i defined share script pipeline in another repository.

          So it always shows two repositories.

          And no error logs in backend.

          Steven added a comment - - edited Yes, for this job, has just one Git repository, but i defined share script pipeline in another repository. So it always shows two repositories. And no error logs in backend.

          Ulli Hafner added a comment -

          Can you please set the ‚SCM‘ parameter in the git reference job computation and the coverage step and retry? Maybe this is the problem.

          Ulli Hafner added a comment - Can you please set the ‚SCM‘ parameter in the git reference job computation and the coverage step and retry? Maybe this is the problem.

          Steven added a comment -

          It works now after add scm parameter in recordCoverage function.

          Thank Hafner for your support.

          Steven added a comment - It works now after add scm parameter in recordCoverage function. Thank Hafner for your support.

          Ulli Hafner added a comment -

          I am reopening because the plugin should at least report the problem. Just ignoring the error does not provide a good user experience.

          Ulli Hafner added a comment - I am reopening because the plugin should at least report the problem. Just ignoring the error does not provide a good user experience.

            drulli Ulli Hafner
            stevens Steven
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: