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

Checkstyle plugin not working in pipeline

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • warnings-plugin
    • None

      Hi all,

      I seem to have hit a possible bug with using the Checkstyle plugin for a pipeline project.

      I have checked that the plugins are all working OK for a freestyle project:

      https://groups.google.com/forum/#!topic/jenkinsci-users/RMyO5zYDABM

      (sorry for the cross post)

      Now if I use the following for a pipeline version of the same project:

      stage('RuboCop code analyzer') {
        node {
          sh '/var/lib/jenkins/ci-projects/test/build-scripts/run-rubocop-tests.sh'
      
          publishHTML(target: [
            allowMissing: false,
            alwaysLinkToLastBuild: true,
            keepAll: true,
            reportDir: '/var/lib/jenkins/ci-projects/test/build-reports/',
            reportFiles: 'rubocop-index.html',
            reportName: 'RuboCop HTML Report'
          ])
        }
      }
      
      stage('Scan for Rubocop compiler Warnings') {
        node {
          step([$class: 'WarningsPublisher',
            canResolveRelativePaths: false,
            consoleParsers: [[parserName: 'Rubocop']],
            defaultEncoding: '',
            excludePattern: '',
            healthy: '',
            includePattern: '',
            messagesPattern: '',
            unHealthy: '',
            useStableBuildAsReference: true
          ])
        }
      }
      
      stage('Rubocop CheckStyle Publisher') {
        node {
          step([$class: 'CheckStylePublisher',
            canRunOnFailed: true,
            defaultEncoding: '',
            healthy: '',
            pattern: '',
            unHealthy: '',
            useStableBuildAsReference: true
          ])
        }
      }
      

      When I do a build of the project, I get the following in the console output:

      [CHECKSTYLE] Collecting checkstyle analysis files...
      [CHECKSTYLE] Finding all files that match the pattern **/checkstyle-result.xml
      [CHECKSTYLE] Computing warning deltas based on reference build #95
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] End of Pipeline
      Finished: SUCCESS

      Now if I click on the build number, I see the following:

      Checkstyle: 0 warnings.
      No warnings since build 1.
      New zero warnings highscore: no warnings for 71 days!
      During parsing an error has been reported.

      So if I click on the error link I get the following message:

      Errors
      No report files were found. Configuration error?

      Yet the build logs tell me that checkstyle has found the report file above.

      Have i missed something here, such as a configuration parameter, or is this a possible bug?

      Kind Regards,

      Keith

      Update:

      If I compare the console output from the freestyle version of the project that generates the Checkstyle warnings OK, and the pipeline version of the same project I get these outputs:

      Freestyle project console output

      14:12:25 [CHECKSTYLE] Collecting checkstyle analysis files...
      14:12:26 [CHECKSTYLE] Finding all files that match the pattern **/rubocop-checkstyle-result.xml
      14:12:26 [CHECKSTYLE] Parsing 1 file in /var/lib/jenkins/workspace/test-freestyle
      14:12:26 [CHECKSTYLE] Successfully parsed file /var/lib/jenkins/workspace/test-freestyle/rubocop-checkstyle-result.xml with 4177 unique warnings and 0 duplicates.
      14:12:27 [CHECKSTYLE] Computing warning deltas based on reference build #65

      Pipeline version console output

      [CHECKSTYLE] Collecting checkstyle analysis files...
      [CHECKSTYLE] Finding all files that match the pattern **/checkstyle-result.xml
      [CHECKSTYLE] Computing warning deltas based on reference build #98

      So it looks like the pipeline version is NOT parsing the xml output file - but the freestyle version is.

      What do I need to do to make the pipeline version parse the said file please?

            drulli Ulli Hafner
            sputnik1 Keith Roberts
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: