1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/vars/mavenExecuteStaticCodeChecks.groovy
Philipp Stehle f9f0cbfd33
enforce that step metadata yaml file is called <step>.yaml (#3226)
Co-authored-by: Philipp Stehle <philipp.stehle@sap.com>
2021-11-15 14:20:20 +01:00

47 lines
1.7 KiB
Groovy

import com.sap.piper.BuildTool
import com.sap.piper.ConfigurationLoader
import com.sap.piper.DownloadCacheUtils
import com.sap.piper.QualityCheck
import com.sap.piper.ReportAggregator
import groovy.transform.Field
import static com.sap.piper.Prerequisites.checkScript
@Field String METADATA_FILE = 'metadata/mavenExecuteStaticCodeChecks.yaml'
@Field String STEP_NAME = getClass().getName()
void call(Map parameters = [:]) {
final script = checkScript(this, parameters) ?: null
List credentials = []
parameters = DownloadCacheUtils.injectDownloadCacheInParameters(script, parameters, BuildTool.MAVEN)
try {
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentials)
} catch (Exception exception) {
error("Maven Static Code Checks execution failed. Please examine the reports which are also available in the Jenkins user interface.")
}
finally {
showIssues(script)
}
}
private showIssues(Script script) {
Map configuration = ConfigurationLoader.stepConfiguration(script, STEP_NAME)
// Every check is executed by default. Only if configured with `false` the check won't be executed
if (!(configuration.spotBugs == false)) {
recordIssues(blameDisabled: true,
enabledForFailure: true,
aggregatingResults: false,
tool: spotBugs(pattern: '**/target/spotbugsXml.xml'))
ReportAggregator.instance.reportStaticCodeExecution(QualityCheck.FindbugsCheck)
}
if (!(configuration.pmd == false)) {
recordIssues(blameDisabled: true,
enabledForFailure: true,
aggregatingResults: false,
tool: pmdParser(pattern: '**/target/pmd.xml'))
ReportAggregator.instance.reportStaticCodeExecution(QualityCheck.PmdCheck)
}
}