github.com/jaylevin/jenkins-library@v1.230.4/vars/hadolintExecute.groovy (about)

     1  import static com.sap.piper.Prerequisites.checkScript
     2  import com.sap.piper.ConfigurationHelper
     3  import com.sap.piper.JenkinsUtils
     4  import com.sap.piper.Utils
     5  import groovy.transform.Field
     6  
     7  @Field String STEP_NAME = getClass().getName()
     8  @Field String METADATA_FILE = 'metadata/hadolintExecute.yaml'
     9  
    10  @Field Set GENERAL_CONFIG_KEYS = []
    11  @Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus([
    12      'qualityGates',
    13      'reportFile',
    14      'reportName'
    15  ])
    16  @Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
    17  
    18  void call(Map parameters = [:]) {
    19      final script = checkScript(this, parameters) ?: null
    20      List credentialInfo = [
    21          [type: 'usernamePassword', id: 'configurationCredentialsId', env: ['PIPER_configurationUsername', 'PIPER_configurationPassword']],
    22      ]
    23  
    24      issuesWrapper(parameters, script){
    25          piperExecuteBin(parameters, STEP_NAME, METADATA_FILE, credentialInfo)
    26      }
    27  }
    28  
    29  def issuesWrapper(Map parameters = [:], Script script, Closure body){
    30      String stageName = parameters.stageName ?: env.STAGE_NAME
    31      // load default & individual configuration
    32      Map config = ConfigurationHelper.newInstance(this)
    33          .loadStepDefaults([:], stageName)
    34          .mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
    35          .mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
    36          .mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS)
    37          .mixin(parameters, PARAMETER_KEYS)
    38          .use()
    39  
    40      try {
    41          body()
    42      } finally {
    43          recordIssues(
    44              blameDisabled: true,
    45              enabledForFailure: true,
    46              aggregatingResults: false,
    47              qualityGates: config.qualityGates,
    48              tool: checkStyle(
    49                  id: config.reportName,
    50                  name: config.reportName,
    51                  pattern: config.reportFile
    52              )
    53          )
    54      }
    55  }