1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/vars/hadolintExecute.groovy

56 lines
1.8 KiB
Groovy
Raw Normal View History

import static com.sap.piper.Prerequisites.checkScript
import com.sap.piper.ConfigurationHelper
refactor(hadolint): implement step in GO (#1169) * initial commit of yaml file * initial commit for HaDoLint in GO * add helper function to load file from url * load config file * write report information to disk * comment the code * refactor groovy code * remove download function from FileUtils * use http.Downloader * rename step files * update generated files * update generated files * remove duplicate commands * add credentials for config url * add generated test file * reuse piperExecuteBin functions * correct step name * update go step * deactivate test * fix import * use differing go step name * rename step * correct result publishing * correct command name * expose tls insecure flag * hand through error * disable tls verification * fix tls disabling * use credentials * mow * reformat * add qgate only if set * correct report name * remove old defaults * add qgate to defaults * handle report name * restore default * remove unused step config * use piperExecuteBin * remove obsolete type * add test cases * remove groovy tests * move client parameter handling to run function * use custom interfaces and mockery * remove commented code * correct struct names * rename parameter dockerfile * add further asserts * cleanup * change file permission to read/write * remove tokenize * add further comments * init http client only if necessary * add todo * Revert "rename parameter dockerfile" This reverts commit 2a570685b89317d20217217894d68242d4620031. * add alias for dockerfile parameter * correct test case * Apply suggestions from code review Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com> * add comment about mock assertions Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
2020-11-16 16:14:54 +02:00
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'
refactor(hadolint): implement step in GO (#1169) * initial commit of yaml file * initial commit for HaDoLint in GO * add helper function to load file from url * load config file * write report information to disk * comment the code * refactor groovy code * remove download function from FileUtils * use http.Downloader * rename step files * update generated files * update generated files * remove duplicate commands * add credentials for config url * add generated test file * reuse piperExecuteBin functions * correct step name * update go step * deactivate test * fix import * use differing go step name * rename step * correct result publishing * correct command name * expose tls insecure flag * hand through error * disable tls verification * fix tls disabling * use credentials * mow * reformat * add qgate only if set * correct report name * remove old defaults * add qgate to defaults * handle report name * restore default * remove unused step config * use piperExecuteBin * remove obsolete type * add test cases * remove groovy tests * move client parameter handling to run function * use custom interfaces and mockery * remove commented code * correct struct names * rename parameter dockerfile * add further asserts * cleanup * change file permission to read/write * remove tokenize * add further comments * init http client only if necessary * add todo * Revert "rename parameter dockerfile" This reverts commit 2a570685b89317d20217217894d68242d4620031. * add alias for dockerfile parameter * correct test case * Apply suggestions from code review Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com> * add comment about mock assertions Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
2020-11-16 16:14:54 +02:00
@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 = [:]) {
refactor(hadolint): implement step in GO (#1169) * initial commit of yaml file * initial commit for HaDoLint in GO * add helper function to load file from url * load config file * write report information to disk * comment the code * refactor groovy code * remove download function from FileUtils * use http.Downloader * rename step files * update generated files * update generated files * remove duplicate commands * add credentials for config url * add generated test file * reuse piperExecuteBin functions * correct step name * update go step * deactivate test * fix import * use differing go step name * rename step * correct result publishing * correct command name * expose tls insecure flag * hand through error * disable tls verification * fix tls disabling * use credentials * mow * reformat * add qgate only if set * correct report name * remove old defaults * add qgate to defaults * handle report name * restore default * remove unused step config * use piperExecuteBin * remove obsolete type * add test cases * remove groovy tests * move client parameter handling to run function * use custom interfaces and mockery * remove commented code * correct struct names * rename parameter dockerfile * add further asserts * cleanup * change file permission to read/write * remove tokenize * add further comments * init http client only if necessary * add todo * Revert "rename parameter dockerfile" This reverts commit 2a570685b89317d20217217894d68242d4620031. * add alias for dockerfile parameter * correct test case * Apply suggestions from code review Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com> * add comment about mock assertions Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
2020-11-16 16:14:54 +02:00
final script = checkScript(this, parameters) ?: null
List credentialInfo = [
[type: 'usernamePassword', id: 'configurationCredentialsId', env: ['PIPER_configurationUsername', 'PIPER_configurationPassword']],
]
refactor(hadolint): implement step in GO (#1169) * initial commit of yaml file * initial commit for HaDoLint in GO * add helper function to load file from url * load config file * write report information to disk * comment the code * refactor groovy code * remove download function from FileUtils * use http.Downloader * rename step files * update generated files * update generated files * remove duplicate commands * add credentials for config url * add generated test file * reuse piperExecuteBin functions * correct step name * update go step * deactivate test * fix import * use differing go step name * rename step * correct result publishing * correct command name * expose tls insecure flag * hand through error * disable tls verification * fix tls disabling * use credentials * mow * reformat * add qgate only if set * correct report name * remove old defaults * add qgate to defaults * handle report name * restore default * remove unused step config * use piperExecuteBin * remove obsolete type * add test cases * remove groovy tests * move client parameter handling to run function * use custom interfaces and mockery * remove commented code * correct struct names * rename parameter dockerfile * add further asserts * cleanup * change file permission to read/write * remove tokenize * add further comments * init http client only if necessary * add todo * Revert "rename parameter dockerfile" This reverts commit 2a570685b89317d20217217894d68242d4620031. * add alias for dockerfile parameter * correct test case * Apply suggestions from code review Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com> * add comment about mock assertions Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
2020-11-16 16:14:54 +02:00
issuesWrapper(parameters, script){
piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentialInfo)
}
}
refactor(hadolint): implement step in GO (#1169) * initial commit of yaml file * initial commit for HaDoLint in GO * add helper function to load file from url * load config file * write report information to disk * comment the code * refactor groovy code * remove download function from FileUtils * use http.Downloader * rename step files * update generated files * update generated files * remove duplicate commands * add credentials for config url * add generated test file * reuse piperExecuteBin functions * correct step name * update go step * deactivate test * fix import * use differing go step name * rename step * correct result publishing * correct command name * expose tls insecure flag * hand through error * disable tls verification * fix tls disabling * use credentials * mow * reformat * add qgate only if set * correct report name * remove old defaults * add qgate to defaults * handle report name * restore default * remove unused step config * use piperExecuteBin * remove obsolete type * add test cases * remove groovy tests * move client parameter handling to run function * use custom interfaces and mockery * remove commented code * correct struct names * rename parameter dockerfile * add further asserts * cleanup * change file permission to read/write * remove tokenize * add further comments * init http client only if necessary * add todo * Revert "rename parameter dockerfile" This reverts commit 2a570685b89317d20217217894d68242d4620031. * add alias for dockerfile parameter * correct test case * Apply suggestions from code review Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com> * add comment about mock assertions Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
2020-11-16 16:14:54 +02:00
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()
refactor(hadolint): implement step in GO (#1169) * initial commit of yaml file * initial commit for HaDoLint in GO * add helper function to load file from url * load config file * write report information to disk * comment the code * refactor groovy code * remove download function from FileUtils * use http.Downloader * rename step files * update generated files * update generated files * remove duplicate commands * add credentials for config url * add generated test file * reuse piperExecuteBin functions * correct step name * update go step * deactivate test * fix import * use differing go step name * rename step * correct result publishing * correct command name * expose tls insecure flag * hand through error * disable tls verification * fix tls disabling * use credentials * mow * reformat * add qgate only if set * correct report name * remove old defaults * add qgate to defaults * handle report name * restore default * remove unused step config * use piperExecuteBin * remove obsolete type * add test cases * remove groovy tests * move client parameter handling to run function * use custom interfaces and mockery * remove commented code * correct struct names * rename parameter dockerfile * add further asserts * cleanup * change file permission to read/write * remove tokenize * add further comments * init http client only if necessary * add todo * Revert "rename parameter dockerfile" This reverts commit 2a570685b89317d20217217894d68242d4620031. * add alias for dockerfile parameter * correct test case * Apply suggestions from code review Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com> * add comment about mock assertions Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
2020-11-16 16:14:54 +02:00
try {
body()
} finally {
recordIssues(
blameDisabled: true,
enabledForFailure: true,
aggregatingResults: false,
qualityGates: config.qualityGates,
tool: checkStyle(
id: config.reportName,
name: config.reportName,
pattern: config.reportFile
)
refactor(hadolint): implement step in GO (#1169) * initial commit of yaml file * initial commit for HaDoLint in GO * add helper function to load file from url * load config file * write report information to disk * comment the code * refactor groovy code * remove download function from FileUtils * use http.Downloader * rename step files * update generated files * update generated files * remove duplicate commands * add credentials for config url * add generated test file * reuse piperExecuteBin functions * correct step name * update go step * deactivate test * fix import * use differing go step name * rename step * correct result publishing * correct command name * expose tls insecure flag * hand through error * disable tls verification * fix tls disabling * use credentials * mow * reformat * add qgate only if set * correct report name * remove old defaults * add qgate to defaults * handle report name * restore default * remove unused step config * use piperExecuteBin * remove obsolete type * add test cases * remove groovy tests * move client parameter handling to run function * use custom interfaces and mockery * remove commented code * correct struct names * rename parameter dockerfile * add further asserts * cleanup * change file permission to read/write * remove tokenize * add further comments * init http client only if necessary * add todo * Revert "rename parameter dockerfile" This reverts commit 2a570685b89317d20217217894d68242d4620031. * add alias for dockerfile parameter * correct test case * Apply suggestions from code review Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com> * add comment about mock assertions Co-authored-by: Stephan Aßmus <stephan.assmus@sap.com>
2020-11-16 16:14:54 +02:00
)
}
}