1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-16 11:09:33 +02:00
sap-jenkins-library/vars/pipelineStashFilesBeforeBuild.groovy

44 lines
1.6 KiB
Groovy
Raw Normal View History

import static com.sap.piper.Prerequisites.checkScript
2018-05-30 12:00:13 +02:00
import com.sap.piper.Utils
import com.sap.piper.ConfigurationHelper
import groovy.transform.Field
@Field String STEP_NAME = getClass().getName()
@Field Set STEP_CONFIG_KEYS = ['noDefaultExludes', 'stashIncludes', 'stashExcludes']
2018-05-30 12:00:13 +02:00
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
2018-08-30 16:33:07 +02:00
void call(Map parameters = [:]) {
2018-05-30 12:00:13 +02:00
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters, stepNameDoc: 'stashFiles') {
Utils utils = parameters.juStabUtils
2018-05-30 12:00:13 +02:00
if (utils == null) {
utils = new Utils()
}
def script = checkScript(this, parameters)
2018-05-30 12:00:13 +02:00
if (script == null)
script = this
2018-05-30 12:00:13 +02:00
Map config = ConfigurationHelper.newInstance(this)
.loadStepDefaults()
2018-05-30 12:00:13 +02:00
.mixinGeneralConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, STEP_CONFIG_KEYS)
2018-05-30 12:00:13 +02:00
.mixin(parameters, PARAMETER_KEYS)
.use()
new Utils().pushToSWA([
step: STEP_NAME,
stepParamKey1: 'scriptMissing',
stepParam1: parameters?.script == null
], config)
config.stashIncludes.each {stashKey, stashIncludes ->
def useDefaultExcludes = !config.noDefaultExludes.contains(stashKey)
utils.stashWithMessage(stashKey, "[${STEP_NAME}] no files detected for stash '${stashKey}': ", stashIncludes, config.stashExcludes[stashKey]?:'', useDefaultExcludes)
2018-05-30 12:00:13 +02:00
}
}
}