0

I have a series of jenkins pipeline jobs which build bitbucket pull requests. Those pipelines have a Quality stage, which records issues using warningsng for GCC warnings and Coverity defects (via the generic issues tool).

The relevant part of my pipeline is:

post {
    always {
        recordIssues(
           blameDisabled: true,
           forensicsDisabled: true,
           tools: [gcc(id: "${env.PRODUCT}-static-gcc",
                       name: "${PRODUCT} GCC warnings",
                       pattern: "rw/build-analysis.log"),
                   issues(id: "${env.PRODUCT}-coverity-defects",
                          name: "${PRODUCT} Coverity Defects",
                          pattern: "rw/warning-ng-defects-*.xml")]
        )
    }
}

Since we have fixed normally all of our GCC warnings, but we still have lots of Coverity defects, I wanted to apply a quality gate to the gcc tool, to reject pull requests with warnings, but not to the issues one, since we accept for now, pull requests still having Coverity defects.

But my understanding, from the reading of the pipeline syntax steps reference, is that a quality gate applies to the whole list of tools in recordIssues, and doesn't seem to be applicable to only one of the tools.

Here's what I had tried:

post {
    always {
        recordIssues(
           blameDisabled: true,
           forensicsDisabled: true,
           tools: [gcc(id: "${env.PRODUCT}-static-gcc",
                       name: "${PRODUCT} GCC warnings",
                       pattern: "rw/build-analysis.log",
                       qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]]),
                   issues(id: "${env.PRODUCT}-coverity-defects",
                          name: "${PRODUCT} Coverity Defects",
                          pattern: "rw/warning-ng-defects-*.xml")]
        )
    }
}

But according to the documentation, it seems logical that it was just plainly ignored.

So, is there a way to apply a quality gate to only one of a tool in a tools list, in recordIssues?

ncarrier
  • 433
  • 3
  • 14
  • 1
    Why not invoke two `recordIssues`: one for the gcc warnings, and the second for the coverity defects? Then you could only pass the `qualityGates` argument to only one of the two. Are you restricted from that usage in your environment? – Matthew Schuchard Mar 07 '22 at 17:02
  • Is it possible? I thought that only one was possible. I'll try that right now and I'll let you know :) – ncarrier Mar 08 '22 at 09:02

1 Answers1

0

So in the end, the solution was simple and "only" consisted in using recordIssues twice. This worked for me:

post {
    always {
        recordIssues(
           blameDisabled: true,
           forensicsDisabled: true,
           tool: issues(id: "${env.PRODUCT}-coverity-defects",
                        name: "${PRODUCT} Coverity Defects",
                        pattern: "rw/warning-ng-defects-*.xml")
        )
        recordIssues(
           blameDisabled: true,
           forensicsDisabled: true,
           qualityGates: [[threshold: 1, type: 'TOTAL', unstable: false]],
           tool: gcc(id: "${env.PRODUCT}-static-gcc",
                     name: "${PRODUCT} GCC warnings",
                     pattern: "rw/build-analysis.log")
        )
    }
}

Thank you very much @MattSchuchard!

ncarrier
  • 433
  • 3
  • 14