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

pmd warnings trend disappear if the last build doesn't record issues

      I have configured my build to run and check PMD only for certain situations. Before Warnings Next Generation plugin, the graph were always shown, even when pmd were not executed.

      Also the link "PMD Warnings" on the top left area is not shown.

      I suspect that "test result trend" have the same problem, and maybe others like checkstyle etc.

          [JENKINS-56083] pmd warnings trend disappear if the last build doesn't record issues

          Ulli Hafner added a comment -

          In a pipeline or in a freestyle job? Can you please show your configuration in more detail?

          Ulli Hafner added a comment - In a pipeline or in a freestyle job? Can you please show your configuration in more detail?

          Andrea me added a comment -

          It's a pipeline, this is my stage script:

          stage('Code analysis') {
          	if (skipCodeAnalysis) {
          		echo '**Skip analysys**'
          	} else {
          		try{
          			sh "./gradlew pmdMain "
          		} catch (e) {
          			failBuild()
          			throw e
          		} finally {
          			//PMD
          			recordIssues enabledForFailure: true, failedTotalHigh: 84, failedTotalNormal: 225, tools: [pmdParser(pattern: '**/reports/pmd/*.xml', reportEncoding: 'UTF-8')]
          		}
          	}
          }
          

          I don't want to run PMD checks on every build because they take too long.
          skipCodeAnalysis is a boolean variable.

          Andrea me added a comment - It's a pipeline, this is my stage script: stage( 'Code analysis' ) { if (skipCodeAnalysis) { echo '**Skip analysys**' } else { try { sh "./gradlew pmdMain " } catch (e) { failBuild() throw e } finally { //PMD recordIssues enabledForFailure: true , failedTotalHigh: 84, failedTotalNormal: 225, tools: [pmdParser(pattern: '**/reports/pmd/*.xml' , reportEncoding: 'UTF-8' )] } } } I don't want to run PMD checks on every build because they take too long. skipCodeAnalysis is a boolean variable.

          Ulli Hafner added a comment - - edited

          If you do not call recordIssues then the job does not contain a so called Action. Then Jenkins does simply not know that there are such results.
          Can you change the code above to something like:

          stage('Code analysis') {
          	if (skipCodeAnalysis) {
          		echo '**Skip analysys**'
          	} else {
          		try{
          			sh "./gradlew pmdMain "
          		} catch (e) {
          			failBuild()
          			throw e
          		} 
          	}
                  recordIssues enabledForFailure: true, failedTotalHigh: 84, failedTotalNormal: 225, tools: [pmdParser(pattern: '**/reports/pmd/*.xml', reportEncoding: 'UTF-8')]
          }
          

          Ulli Hafner added a comment - - edited If you do not call recordIssues then the job does not contain a so called Action . Then Jenkins does simply not know that there are such results. Can you change the code above to something like: stage( 'Code analysis' ) { if (skipCodeAnalysis) { echo '**Skip analysys**' } else { try { sh "./gradlew pmdMain " } catch (e) { failBuild() throw e } } recordIssues enabledForFailure: true , failedTotalHigh: 84, failedTotalNormal: 225, tools: [pmdParser(pattern: '**/reports/pmd/*.xml' , reportEncoding: 'UTF-8' )] }

          Andrea me added a comment -

          I'm aware that recordIssues must run to collect issues, but my build is running inside a docker container and it doesn't persist its state because it's a branch build.  I also need to run PMD only in certain cases, that's why I don't run recordIssues  every time.

          Before the release of warnings-ng-plugin, the graph where always shown if one or more previous builds were run. But the latest (or more) build without errors was not included in the chart.

          Andrea me added a comment - I'm aware that recordIssues must run to collect issues, but my build is running inside a docker container and it doesn't persist its state because it's a branch build.  I also need to run PMD only in certain cases, that's why I don't run recordIssues  every time. Before the release of warnings-ng-plugin, the graph where always shown if one or more previous builds were run. But the latest (or more) build without errors was not included in the chart.

            Unassigned Unassigned
            regrog Andrea me
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: