2020-03-30 15:59:59 +02:00
|
|
|
import com.sap.piper.ConfigurationLoader
|
2020-03-23 10:58:54 +02:00
|
|
|
import com.sap.piper.DownloadCacheUtils
|
2020-03-30 15:59:59 +02:00
|
|
|
import com.sap.piper.QualityCheck
|
|
|
|
import com.sap.piper.ReportAggregator
|
2020-03-12 16:45:57 +02:00
|
|
|
import groovy.transform.Field
|
|
|
|
|
2020-03-30 15:59:59 +02:00
|
|
|
import static com.sap.piper.Prerequisites.checkScript
|
|
|
|
|
2020-03-12 16:45:57 +02:00
|
|
|
@Field String METADATA_FILE = 'metadata/mavenStaticCodeChecks.yaml'
|
|
|
|
@Field String STEP_NAME = getClass().getName()
|
|
|
|
|
|
|
|
void call(Map parameters = [:]) {
|
2020-03-30 15:59:59 +02:00
|
|
|
final script = checkScript(this, parameters) ?: null
|
2020-03-23 10:58:54 +02:00
|
|
|
List credentials = []
|
2020-03-30 15:59:59 +02:00
|
|
|
parameters = DownloadCacheUtils.injectDownloadCacheInMavenParameters(script, parameters)
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
2020-03-12 16:45:57 +02:00
|
|
|
}
|