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

Cannot resolve relative filenames referencing parent directory

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • warnings-plugin
    • None
    • Ubuntu 15.10 64 bit, OpenJDK
      Jenkins 1.642
      Warnings plug-in 4.51

      Warnings plugin cannot resolve some relative file names even if "Resolve relative paths" option is set. There are problems with names such as ../file. In that case it cannot find that file even if its name is unique across the entire workspace (but it can resolve "file" without ".." in the same build).

      STEPS TO REPRODUCE

      1. Create empty Git repository
      2. Unpack the archive attached and commit
      3. Create new Freestyle project
        • source control: git
        • build steps: none
        • post-build steps: scan workspace files (compile-log.txt, "Clang (LLVM based)"), set the "Resole relative paths" option
        • build is conducted on the master
      4. Build project and examine warnings

      WHAT IS EXPECTED
      On Files tab one should see one file.txt, one file-in-subdir.txt and one or several multi-file-in-subdir.txt (this file name contained multiple times in the workspace).
      For all warnings in file.txt and file-in-subdir.txt one can view source (because these files have unique names across workspace).

      WHAT HAPPENS
      file-in-subdir.txt is listed twice on Files tab. I cannot view source for warning where it is referenced as ../file-in-subdir.txt (but the source is viewable for warning without ".." in filename).

      CONTENTS OF hudson.plugins.analysis.core.ParserResult (FINE) LOG

      дек 20, 2015 3:07:21 PM FINE hudson.plugins.analysis.core.ParserResult
      Building cache of all workspace files to obtain absolute filenames for all warnings: /var/lib/jenkins/workspace/Test
      дек 20, 2015 3:07:21 PM FINE hudson.plugins.analysis.core.ParserResult
      Absolute filename could not be resolved for: ../multi-file-in-subdir.txt. Found multiple matches: [directory-b/multi-file-in-subdir.txt, directory-a/multi-file-in-subdir.txt]. 
      дек 20, 2015 3:07:21 PM FINE hudson.plugins.analysis.core.ParserResult
      Absolute filename could not be resolved for: ../file-in-subdir.txt. Found multiple matches: [directory-a/file-in-subdir.txt]. 
      дек 20, 2015 3:07:21 PM FINE hudson.plugins.analysis.core.ParserResult
      Absolute filename could not be resolved for: multi-file-in-subdir.txt. Found multiple matches: [directory-b/multi-file-in-subdir.txt, directory-a/multi-file-in-subdir.txt]. 
      дек 20, 2015 3:07:21 PM FINE hudson.plugins.analysis.core.ParserResult
      Absolute filename could not be resolved for: multi-file-in-subdir.txt. Found multiple matches: [directory-b/multi-file-in-subdir.txt, directory-a/multi-file-in-subdir.txt]. 
      дек 20, 2015 3:07:21 PM FINE hudson.plugins.analysis.core.ParserResult
      Absolute filename could not be resolved for: ../file-in-subdir.txt. Found multiple matches: [directory-a/file-in-subdir.txt]. 
      дек 20, 2015 3:07:21 PM FINE hudson.plugins.analysis.core.ParserResult
      Absolute filename could not be resolved for: ../multi-file-in-subdir.txt. Found multiple matches: [directory-b/multi-file-in-subdir.txt, directory-a/multi-file-in-subdir.txt]. 
      

      ERRROR MESSAGE

      01 Copying the source file '../file-in-subdir.txt' from the workspace to the build folder '53f2b315.tmp' on the Jenkins master failed.
      02 Seems that the path is relative, however an absolute path is required when copying the sources.
      03 Is the file 'file-in-subdir.txt' contained more than once in your workspace?
      04 Is the file '../file-in-subdir.txt' a valid filename?
      05 If you are building on a slave: please check if the file is accessible under '$JENKINS_HOME/[job-name]/../file-in-subdir.txt'
      06 If you are building on the master: please check if the file is accessible under '$JENKINS_HOME/[job-name]/workspace/../file-in-subdir.txt'
      07 java.io.IOException: Failed to copy ../file-in-subdir.txt to /var/lib/jenkins/jobs/Test/builds/2/workspace-files/53f2b315.tmp
      08   at hudson.FilePath.copyTo(FilePath.java:1990)
      09   at hudson.plugins.analysis.util.Files.copyFilesWithAnnotationsToBuildFolder(Files.java:80)
      10   at hudson.plugins.analysis.core.HealthAwareRecorder.copyFilesWithAnnotationsToBuildFolder(HealthAwareRecorder.java:312)
      11   at hudson.plugins.analysis.core.HealthAwarePublisher.perform(HealthAwarePublisher.java:89)
      12   at hudson.plugins.analysis.core.HealthAwareRecorder.perform(HealthAwareRecorder.java:259)
      13   at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
      14   at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      15   at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
      16   at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
      17   at hudson.model.Build$BuildExecution.post2(Build.java:185)
      18   at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
      19   at hudson.model.Run.execute(Run.java:1763)
      20   at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      21   at hudson.model.ResourceController.execute(ResourceController.java:98)
      22   at hudson.model.Executor.run(Executor.java:410)
      23 Caused by: java.io.FileNotFoundException: ../file-in-subdir.txt (Нет такого файла или каталога)
      24   at java.io.FileInputStream.open(Native Method)
      25   at java.io.FileInputStream.<init>(FileInputStream.java:146)
      26   at hudson.FilePath$41.invoke(FilePath.java:2016)
      27   at hudson.FilePath$41.invoke(FilePath.java:2011)
      28   at hudson.FilePath.act(FilePath.java:990)
      29   at hudson.FilePath.act(FilePath.java:968)
      30   at hudson.FilePath.copyTo(FilePath.java:2011)
      31   at hudson.FilePath.copyTo(FilePath.java:1985)
      32   ... 14 more
      

          [JENKINS-32150] Cannot resolve relative filenames referencing parent directory

          Anatoly Trosinenko created issue -

          Ulli Hafner added a comment -

          Are you using make as build script?

          Ulli Hafner added a comment - Are you using make as build script?
          Ulli Hafner made changes -
          Link New: This issue depends on JENKINS-14064 [ JENKINS-14064 ]

          In this example I just use prewritten lines that are parseable as LLVM warnings without any make output. Non-unique file name is for comparison only (make output parser is useful for that case as far as I know), but the report is about different handling of the same unique basename with and without "..".

          Anatoly Trosinenko added a comment - In this example I just use prewritten lines that are parseable as LLVM warnings without any make output. Non-unique file name is for comparison only (make output parser is useful for that case as far as I know), but the report is about different handling of the same unique basename with and without "..".

          Ulli Hafner added a comment -

          I just asked because with make a possible solution already has been implemented for the gcc parser. That patch then just needs to be generalized.

          Without make I doubt that we find a solution that works in all cases.

          Ulli Hafner added a comment - I just asked because with make a possible solution already has been implemented for the gcc parser. That patch then just needs to be generalized. Without make I doubt that we find a solution that works in all cases.

          In JENKINS-9463 there was proposal to use just basename to resolve relative paths and you told that it was already done in that way. I am not sure that this approach will not break anything, but if relative paths are still supposed to be resolved by basename only, then something goes wrong.

          PS: The message "Found multiple matches: [directory-a/file-in-subdir.txt]." seems strange.

          Anatoly Trosinenko added a comment - In JENKINS-9463 there was proposal to use just basename to resolve relative paths and you told that it was already done in that way. I am not sure that this approach will not break anything, but if relative paths are still supposed to be resolved by basename only, then something goes wrong. PS: The message "Found multiple matches: [directory-a/file-in-subdir.txt] ." seems strange.

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/main/java/hudson/plugins/analysis/core/ParserResult.java
          src/test/java/hudson/plugins/analysis/core/ParserResultTest.java
          http://jenkins-ci.org/commit/analysis-core-plugin/b864544a789d69fbf59e675465b83426336ebace
          Log:
          [FIXED JENKINS-32150] Remove leading relative path components to parent directories when finding files in the workspace.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/main/java/hudson/plugins/analysis/core/ParserResult.java src/test/java/hudson/plugins/analysis/core/ParserResultTest.java http://jenkins-ci.org/commit/analysis-core-plugin/b864544a789d69fbf59e675465b83426336ebace Log: [FIXED JENKINS-32150] Remove leading relative path components to parent directories when finding files in the workspace.
          SCM/JIRA link daemon made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          Ulli Hafner added a comment -

          Thanks for the valuable test case!

          Ulli Hafner added a comment - Thanks for the valuable test case!

          Code changed in jenkins
          User: Ulli Hafner
          Path:
          src/main/java/org/jenkinsci/test/acceptance/plugins/analysis_core/AnalysisAction.java
          src/main/java/org/jenkinsci/test/acceptance/plugins/analysis_core/AnalysisSettings.java
          src/test/java/plugins/WarningsPluginTest.java
          src/test/resources/warnings_plugin/jenkins-32150/compile-log.txt
          src/test/resources/warnings_plugin/jenkins-32150/directory-a/file-in-subdir.txt
          src/test/resources/warnings_plugin/jenkins-32150/directory-a/multi-file-in-subdir.txt
          src/test/resources/warnings_plugin/jenkins-32150/directory-a/subdir/file1
          src/test/resources/warnings_plugin/jenkins-32150/directory-b/multi-file-in-subdir.txt
          src/test/resources/warnings_plugin/jenkins-32150/directory-b/subdir/file2
          src/test/resources/warnings_plugin/jenkins-32150/file.txt
          http://jenkins-ci.org/commit/acceptance-test-harness/cee24aa85bec9ca281ba2762459d17e0cbe1da2b
          Log:
          JENKINS-32150 Added acceptance test that verifies resolving of paths by scanning the whole workspace.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Ulli Hafner Path: src/main/java/org/jenkinsci/test/acceptance/plugins/analysis_core/AnalysisAction.java src/main/java/org/jenkinsci/test/acceptance/plugins/analysis_core/AnalysisSettings.java src/test/java/plugins/WarningsPluginTest.java src/test/resources/warnings_plugin/jenkins-32150/compile-log.txt src/test/resources/warnings_plugin/jenkins-32150/directory-a/file-in-subdir.txt src/test/resources/warnings_plugin/jenkins-32150/directory-a/multi-file-in-subdir.txt src/test/resources/warnings_plugin/jenkins-32150/directory-a/subdir/file1 src/test/resources/warnings_plugin/jenkins-32150/directory-b/multi-file-in-subdir.txt src/test/resources/warnings_plugin/jenkins-32150/directory-b/subdir/file2 src/test/resources/warnings_plugin/jenkins-32150/file.txt http://jenkins-ci.org/commit/acceptance-test-harness/cee24aa85bec9ca281ba2762459d17e0cbe1da2b Log: JENKINS-32150 Added acceptance test that verifies resolving of paths by scanning the whole workspace.

            drulli Ulli Hafner
            atrosinenko Anatoly Trosinenko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: