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

Files not picked up correctly when root directory is a symlink

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • warnings-ng-plugin
    • None

      Firstly, I'm fairly new to Jenkins, so apologies if I'm not providing useful details or if I'm using the wrong terminology. This issue could also be pilot error, apologies if so.

      I have created a multi-branch pipeline using the Github branch source plugin that runs a maven build and uses recordIssues to pick up Javac, ErrorProne and Spotbugs issues, as well as scanning for open tasks (TODOs etc).

      My Jenkins root path is "/apps/jenkins/latest", which is a symlink to "/apps/jenkins/2.414.1". This seems to throw off the analysis tools, as all the errors from Javac etc. in the console output use the full resolved path (i.e. paths starting with "/apps/jenkins/2.414.1", and the plugin then fails to find those files in the workspace as it's looking for files relative to "/apps/jenkins/latest").

      This affects all the tools, with the exception of the tasks scanner, which I'm assuming the warnings plugin is invoking rather than just consuming a report/console output from.

      As far as I can tell the impact of this is:

      • I cannot click through to see the code annotated with warnings in the Jenkins UI
      • I do not see "SCM Blames" or "SCM Forensics" tabs in the Details view
      • The files in the PR with warnings do not get GitHub check annotations

      All of this works as expected for the open tasks scanner.

      Some additional information, in case it's useful:


      Here is my pipeline:

      pipeline {
          agent any
      
          tools {
              maven 'Maven 3'
              jdk 'Java 11'
          }
      
          stages {
              stage('Git mining') {
                  steps {
                      discoverReferenceBuild()
                      mineRepository()
                      gitDiffStat()
                  }
              }
      
              stage('Compile') {
                  steps {
                      sh 'mvn --no-transfer-progress clean install -DskipTests'
                      recordIssues(tools: [
                          errorProne(reportEncoding: 'UTF-8'),
                          java(reportEncoding: 'UTF-8'),
                          mavenConsole(),
                          taskScanner(highTags:'FIXME', normalTags:'TODO', includePattern: '**/*.java', excludePattern: 'target/**/*')])
                  }
              }
      
              stage('Static Analysis') {
                  steps {
                      sh 'mvn --no-transfer-progress spotbugs:spotbugs'
                      recordIssues(tools: [spotBugs(reportEncoding: 'UTF-8', useRankAsPriority: true)])
                  }
              }
          }
      }
      

      When I run this in the Jenkins script console:

      println("Root path: ${Jenkins.instance.getRootPath()}")
      println("Resolved root path: ${Jenkins.instance.getRootPath().readLink()}")
      

      I get the following output:

      Root path: /apps/jenkins/latest
      Resolved root path: /apps/jenkins/2.414.1
      

      The checks have warning icons next to them when I view the info page for a build. The tooltip on the icon is:

      Some errors have been logged during recording, click to see these errors in a details view.

      When I go to that details view I see logs like this (this is for ErrorProne):

      Error Messages:

      Errors while obtaining repository statistics
      No statistics found for file '../../../2.414.1/workspace/<job_name>_PR-<pr_number>/path/to/file.java'
      <19 more of these>
        ... skipped logging of 125 additional errors ...
      

      Information Messages

      Parsing console log (workspace: '/apps/jenkins/latest/workspace/<job_name>_PR-<pr_number>')
      Successfully parsed console log
      -> found 195 issues (skipped 0 duplicates)
      Post processing issues on 'Master' with source code encoding 'US-ASCII'
      Creating SCM blamer to obtain author and commit information for affected files
      -> Git blamer successfully created in working tree '/apps/jenkins/latest/workspace/<job_name>_PR-<pr_number>'
      Resolving file names for all issues in workspace '/apps/jenkins/latest/workspace/<job_name>_PR-<pr_number>'
      -> resolved paths in source directory (145 found, 0 not found)
      Resolving module names from module definitions (build.xml, pom.xml, or Manifest.mf files)
      -> resolved module names for 195 issues
      Resolving package names (or namespaces) by parsing the affected files
      -> resolved package names of 145 affected files
      No filter has been set, publishing all 195 issues
      Creating fingerprints for all affected code blocks to track issues over different builds
      -> created fingerprints for 195 issues (skipped 0 issues)
      Invoking Git blamer to create author and commit information for 145 affected files
      -> GIT_COMMIT env = 'HEAD'
      -> Git commit ID = '<sha>'
      -> Git working tree = '/apps/jenkins/latest/workspace/<job_name>_PR-<pr_number>'
      -> blamed authors of issues in 0 files
      Blaming of authors took 1 seconds
      Copying affected files to Jenkins' build folder '/apps/jenkins/latest/jobs/<job_name>/branches/PR-<pr_number>/builds/5/files-with-issues'
      -> 0 copied, 195 not in workspace, 0 not-found, 0 with I/O error
      Extracting repository forensics for 145 affected files (files in repository: 1676)
      -> 0 affected files processed
      Obtaining reference build from reference recorder
      -> Found '<job name> ยป master #1'
      Using reference build '<job name>/master #1' to compute new, fixed, and outstanding issues
      Issues delta (vs. reference build): outstanding: 142, new: 53, fixed: 53
      No quality gates have been set - skipping
      Health report is disabled - skipping
      Created analysis result for 195 issues (found 53 new issues, fixed 53 issues)
      Attaching ResultAction with ID 'error-prone' to build '<job name>/PR-<pr_number> #5'.
      

            drulli Ulli Hafner
            ljrmorgan Louis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: