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

Do not throw exception during hash computation if source code is not available

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • analysis-core-plugin
    • None

      Hi there

      First of all - sorry if this is not the right way of asking such questions.

      I'm trying to migrate from freestyle PMD plugin based duplication report to pipelines DRY plugin based duplication report.

      In our build flow, we launch ant build that produces cpd-pmd XML report inside of a docker container. This docker image/container is the only place where source code lives.
      After XML is ready it is copied to a side and docker container is destroyed.

      On next pipeline step I'm trying to publish DRY report which fails with
      java.io.FileNotFoundException: /var/www/project/sourceFile.php (No such file or directory)

      I've traced this to below line in dry plugin source code:
      https://github.com/jenkinsci/dry-plugin/blob/dry-2.46/src/main/java/hudson/plugins/dry/parser/DuplicationParserRegistry.java#L91

      I understand the reason why exception is thrown - plugin excepts/assumes that all the files mentioned in XML are available and it calculates some kind of hash for each (probably for diffing with previous runs reasons - just guessing).

      Since XML itself contains enough information to make the report itself - I would love to see an option that could be used to disable this part of code.

      Is it reasonable/possible to implement such improvement within dry plugin?

          [JENKINS-41323] Do not throw exception during hash computation if source code is not available

          Ulli Hafner added a comment -

          I think it should not harm if I replace the exception with a logging statement (or ignore it anyway). The error will show up anyway when you click into the source code view that should visualize the warning (not as exception but as a error message in the view).

          Note that without source files the detection of new and fixed warnings will not work well.

          Ulli Hafner added a comment - I think it should not harm if I replace the exception with a logging statement (or ignore it anyway). The error will show up anyway when you click into the source code view that should visualize the warning (not as exception but as a error message in the view). Note that without source files the detection of new and fixed warnings will not work well.

          Thanks drulli for picking this up.
          I'm aware that those additional functionalities won't work as expected but this is IMO justified as long as core functionality (publishing the base report information) is there.

          Łukasz Wojciechowski added a comment - Thanks drulli for picking this up. I'm aware that those additional functionalities won't work as expected but this is IMO justified as long as core functionality (publishing the base report information) is there.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/main/java/hudson/plugins/analysis/util/ContextHashCode.java
          http://jenkins-ci.org/commit/analysis-core-plugin/8538c6ee3ce7774ee0113d9de651e7bc70bcfd5d
          Log:
          [FIXED JENKINS-41323] Use filename as hash code on IO exceptions.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/main/java/hudson/plugins/analysis/util/ContextHashCode.java http://jenkins-ci.org/commit/analysis-core-plugin/8538c6ee3ce7774ee0113d9de651e7bc70bcfd5d Log: [FIXED JENKINS-41323] Use filename as hash code on IO exceptions.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/main/java/hudson/plugins/analysis/core/AbstractAnnotationParser.java
          src/main/java/hudson/plugins/analysis/core/AnnotationsClassifier.java
          http://jenkins-ci.org/commit/analysis-core-plugin/cf832abe4b6fd605345ef042c611aae1602f8976
          Log:
          JENKINS-41323 Use filename as hash code on IO exceptions.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/main/java/hudson/plugins/analysis/core/AbstractAnnotationParser.java src/main/java/hudson/plugins/analysis/core/AnnotationsClassifier.java http://jenkins-ci.org/commit/analysis-core-plugin/cf832abe4b6fd605345ef042c611aae1602f8976 Log: JENKINS-41323 Use filename as hash code on IO exceptions.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          dry.iml
          pom.xml
          src/main/java/hudson/plugins/dry/parser/DuplicationParserRegistry.java
          http://jenkins-ci.org/commit/dry-plugin/fb0c13b27b367a5273e0dd40fc44cada19a32be5
          Log:
          JENKINS-41323 Use filename as hash code on IO exceptions.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: dry.iml pom.xml src/main/java/hudson/plugins/dry/parser/DuplicationParserRegistry.java http://jenkins-ci.org/commit/dry-plugin/fb0c13b27b367a5273e0dd40fc44cada19a32be5 Log: JENKINS-41323 Use filename as hash code on IO exceptions.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          checkstyle.iml
          http://jenkins-ci.org/commit/checkstyle-plugin/db1c028e0ed2a4ae26551a6cadf2dd84dcf0b90f
          Log:
          [FIXED JENKINS-41323] Use filename as hash code on IO exceptions.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: checkstyle.iml http://jenkins-ci.org/commit/checkstyle-plugin/db1c028e0ed2a4ae26551a6cadf2dd84dcf0b90f Log: [FIXED JENKINS-41323] Use filename as hash code on IO exceptions.

            drulli Ulli Hafner
            lukaswoj Łukasz Wojciechowski
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: