Emenda / klocwork-plugin

Jenkins Klocwork Plugin
1 stars 3 forks source link

klocworkQualityGateway pipeline step marks job as failure #38

Closed jvroutak closed 6 years ago

jvroutak commented 6 years ago

Diff Quality Gateway always sets build as failed if threshold is exceeded. So, if I have

                    // Perform Klocwork quality gateway.
                    klocworkQualityGateway([
                        enableDesktopGateway: true,
                        gatewayDesktopConfig: [
                            reportFile: 'kw_report.xml',
                            stopBuild: false,
                            threshold: '1']])

It will always mark the build as failure if any issues are found. I would rather have the control to choose whether the build is unstable or failure because the rest of the job usually depends on the result.

I think a better solution would be to reuse the design for Full Integration Analysis configuration (which already includes the option to choose build result, threshold and stop if failed/unstable, just the Search Query and Condition Name fields would need to be disabled. But that would break backwards compatibility. Another reasonable solution for pipeline users would be to leave build result untouched and instead return the result and let pipeline handle it.

Jenkins Result can only get worse, so it's not even possible to set result to Unstable after the step.

Currently there is a workaround of setting the threshold to large enough value and parsing the resulting report file:

                    // Perform Klocwork quality gateway.
                    klocworkQualityGateway([
                        enableDesktopGateway: true,
                        gatewayDesktopConfig: [
                            reportFile: 'kw_report.xml',
                            stopBuild: false,
                            threshold: '1000000']])

                    // If new defects were found, keep artifacts and mark build as unstable
                    if (readFile('kw_report.xml').contains("problemID")) {
                        currentBuild.result = 'UNSTABLE'
                        archiveArtifacts allowEmptyArchive: true, 
                                         artifacts: 'kw_report.xml'
                    }

Needless to say, that's not a terribly elegant solution.