1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-02-07 13:42:23 +02:00
sap-jenkins-library/vars/hadolintExecute.groovy
Oliver Feldmann fe2e4e7757
chore: switch to new parameter name (#4968)
* chore: switch to new parameter name

Since warnings-ng plugin version 11 the blameDisabled parameter
has been replaced by skipBlames.
To be compatible with Jenkinsfile Runner we put the recordIssues step
into a try/catch, so no exception is thrown and the build fails.

* docs: improve wording

Co-authored-by: Srinikitha Kondreddy <srinikitha.kondreddy@sap.com>

---------

Co-authored-by: Srinikitha Kondreddy <srinikitha.kondreddy@sap.com>
2024-06-28 13:17:21 +02:00

61 lines
2.0 KiB
Groovy

import static com.sap.piper.Prerequisites.checkScript
import com.sap.piper.ConfigurationHelper
import com.sap.piper.JenkinsUtils
import com.sap.piper.Utils
import groovy.transform.Field
@Field String STEP_NAME = getClass().getName()
@Field String METADATA_FILE = 'metadata/hadolintExecute.yaml'
@Field Set GENERAL_CONFIG_KEYS = []
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus([
'qualityGates',
'reportFile',
'reportName'
])
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
void call(Map parameters = [:]) {
final script = checkScript(this, parameters) ?: null
List credentialInfo = [
[type: 'usernamePassword', id: 'configurationCredentialsId', env: ['PIPER_configurationUsername', 'PIPER_configurationPassword']],
]
issuesWrapper(parameters, script){
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentialInfo)
}
}
def issuesWrapper(Map parameters = [:], Script script, Closure body){
String stageName = parameters.stageName ?: env.STAGE_NAME
// load default & individual configuration
Map config = ConfigurationHelper.newInstance(this)
.loadStepDefaults([:], stageName)
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
.mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS)
.mixin(parameters, PARAMETER_KEYS)
.use()
try {
body()
} finally {
try {
recordIssues(
skipBlames: true,
enabledForFailure: true,
aggregatingResults: false,
qualityGates: config.qualityGates,
tool: checkStyle(
id: config.reportName,
name: config.reportName,
pattern: config.reportFile
)
)
} catch (e) {
echo "recordIssues has failed. Possibly due to an outdated version of the warnings-ng plugin."
e.printStackTrace()
}
}
}