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

publishCppcheck in pipeline fails job not stage

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • cppcheck-plugin
    • None

      When cppcheck finds an error publishCppcheck writes the following in the log:

      [Cppcheck] Starting the cppcheck analysis.
      [Cppcheck] Processing 1 files with the pattern 'cppcheck_report.xml'.
      [Cppcheck] Setting build status to FAILURE since total number of issues '1' exceeds the threshold value '0'.
      [Cppcheck] Ending the cppcheck analysis.

      but the stage it runs in is not marked as failed. I have tried using publishCppcheck in both steps and post sections and it makes no difference.

          [JENKINS-54246] publishCppcheck in pipeline fails job not stage

          tsondergaard added a comment -

          This is still a problem. Is there anything I can do to help?

          tsondergaard added a comment - This is still a problem. Is there anything I can do to help?

          tsondergaard added a comment -

          Some information that I believe is relevant:

          Specifically it looks from the junit-plugin pull request that something like this will mark the step failed:

          FlowNode node = getContext().get(FlowNode.class);
          node.addOrReplaceAction(new WarningAction(Result.FAILURE).withMessage("<Some explanation here>"));
          

          I think stuff like that simply has to be added in CppcheckPublisher.perform().

          tsondergaard added a comment - Some information that I believe is relevant: https://www.jenkins.io/blog/2019/07/05/jenkins-pipeline-stage-result-visualization-improvements/ https://groups.google.com/forum/#!msg/jenkinsci-dev/5A7U1KmfX08/IP5Bg_OaAgAJ https://github.com/jenkinsci/junit-plugin/pull/118 Specifically it looks from the junit-plugin pull request that something like this will mark the step failed: FlowNode node = getContext().get(FlowNode.class); node.addOrReplaceAction( new WarningAction(Result.FAILURE).withMessage( "<Some explanation here>" )); I think stuff like that simply has to be added in CppcheckPublisher.perform().

          tsondergaard thank you for filing this. I have the exact same issue. Have you found any working solution in the meantime?

          edward reesman added a comment - tsondergaard thank you for filing this. I have the exact same issue. Have you found any working solution in the meantime?

          tsondergaard added a comment - - edited

          ereesmanar, nope we still have the problem.

          tsondergaard added a comment - - edited ereesmanar , nope we still have the problem.

          thank you for following up tsondergaard - if you do ever discover a nice workaround for this issue, please do try and remember to share your findings with us here! good luck.

          edward reesman added a comment - thank you for following up tsondergaard - if you do ever discover a nice workaround for this issue, please do try and remember to share your findings with us here! good luck.

          If you still need a workaround, place this after publishCppcheck:

          script {
          	if (manager.logContains('.*Setting build status to FAILURE.*')) {
          		error('CppCheck errors detected')
          	}
          }
          

          Or replace publishCppcheck with the Warnings-NG plugin, e.g.:

          recordIssues tool: cppCheck(pattern: 'cppCheckResultsProjectA_*.xml', id: 'project-a-cppcheck', name: 'Project A CppCheck'), publishAllIssues: true, qualityGates: [[threshold: 1, type: 'TOTAL', unstable: false]]
          

          This also works better if the pipeline has multiple CppCheck stages because publishCppcheck cannot handle that.

          Maurice Gilden added a comment - If you still need a workaround, place this after publishCppcheck: script { if (manager.logContains( '.*Setting build status to FAILURE.*' )) { error( 'CppCheck errors detected' ) } } Or replace publishCppcheck with the Warnings-NG plugin , e.g.: recordIssues tool: cppCheck(pattern: 'cppCheckResultsProjectA_*.xml' , id: 'project-a-cppcheck' , name: 'Project A CppCheck' ), publishAllIssues: true , qualityGates: [[threshold: 1, type: 'TOTAL' , unstable: false ]] This also works better if the pipeline has multiple CppCheck stages because publishCppcheck cannot handle that.

            marcosteffan Marco Steffan
            tsondergaard tsondergaard
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: