Apply a quality gate to only one of the tools

672 views Asked by At

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?

1

There are 1 answers

0
ncarrier On BEST ANSWER

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!