2018-09-21 16:55:31 +02:00
|
|
|
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 = 'pipelineStashFilesBeforeBuild'
|
|
|
|
@Field Set STEP_CONFIG_KEYS = ['runOpaTests', 'stashIncludes', 'stashExcludes']
|
|
|
|
@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') {
|
|
|
|
|
|
|
|
def utils = parameters.juStabUtils
|
|
|
|
if (utils == null) {
|
|
|
|
utils = new Utils()
|
|
|
|
}
|
|
|
|
|
2018-09-21 16:55:31 +02:00
|
|
|
def script = checkScript(this, parameters)
|
2018-05-30 12:00:13 +02:00
|
|
|
if (script == null)
|
2018-10-31 09:40:12 +02:00
|
|
|
script = this
|
2018-05-30 12:00:13 +02:00
|
|
|
|
|
|
|
//additional includes via passing e.g. stashIncludes: [opa5: '**/*.include']
|
|
|
|
//additional excludes via passing e.g. stashExcludes: [opa5: '**/*.exclude']
|
|
|
|
|
2018-10-17 11:05:20 +02:00
|
|
|
Map config = ConfigurationHelper.newInstance(this)
|
2018-09-07 10:08:16 +02:00
|
|
|
.loadStepDefaults()
|
2018-05-30 12:00:13 +02:00
|
|
|
.mixinGeneralConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
|
|
|
|
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
|
2018-08-15 10:37:34 +02:00
|
|
|
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, STEP_CONFIG_KEYS)
|
2018-05-30 12:00:13 +02:00
|
|
|
.mixin(parameters, PARAMETER_KEYS)
|
|
|
|
.use()
|
|
|
|
|
2018-10-30 17:22:42 +02:00
|
|
|
new Utils().pushToSWA([step: STEP_NAME,
|
2018-11-05 13:51:33 +02:00
|
|
|
stepParam1: parameters?.script == null], config)
|
2018-08-09 11:35:33 +02:00
|
|
|
|
2018-05-30 12:00:13 +02:00
|
|
|
if (config.runOpaTests){
|
|
|
|
utils.stash('opa5', config.stashIncludes?.get('opa5')?config.stashIncludes.opa5:'**/*.*', config.stashExcludes?.get('opa5')?config.stashExcludes.opa5:'')
|
|
|
|
}
|
|
|
|
|
|
|
|
//store build descriptor files depending on technology, e.g. pom.xml, package.json
|
|
|
|
utils.stash(
|
|
|
|
'buildDescriptor',
|
|
|
|
config.stashIncludes.buildDescriptor,
|
|
|
|
config.stashExcludes.buildDescriptor
|
|
|
|
)
|
|
|
|
//store deployment descriptor files depending on technology, e.g. *.mtaext.yml
|
|
|
|
utils.stashWithMessage(
|
|
|
|
'deployDescriptor',
|
2018-11-20 17:03:07 +02:00
|
|
|
"[${STEP_NAME}] no deployment descriptor files provided: ",
|
2018-05-30 12:00:13 +02:00
|
|
|
config.stashIncludes.deployDescriptor,
|
|
|
|
config.stashExcludes.deployDescriptor
|
|
|
|
)
|
2018-06-01 12:33:06 +02:00
|
|
|
//store git metadata for SourceClear agent
|
|
|
|
sh "mkdir -p gitmetadata"
|
|
|
|
sh "cp -rf .git/* gitmetadata"
|
|
|
|
sh "chmod -R u+w gitmetadata"
|
2018-05-30 12:00:13 +02:00
|
|
|
utils.stashWithMessage(
|
2018-06-01 12:33:06 +02:00
|
|
|
'git',
|
2018-11-20 17:03:07 +02:00
|
|
|
"[${STEP_NAME}] no git repo files detected: ",
|
2018-06-01 12:33:06 +02:00
|
|
|
config.stashIncludes.git,
|
|
|
|
config.stashExcludes.git
|
2018-05-30 12:00:13 +02:00
|
|
|
)
|
2018-06-01 12:33:06 +02:00
|
|
|
//store nsp & retire exclusion file for future use
|
2018-05-30 12:00:13 +02:00
|
|
|
utils.stashWithMessage(
|
2018-06-01 12:33:06 +02:00
|
|
|
'opensourceConfiguration',
|
2018-11-20 17:03:07 +02:00
|
|
|
"[${STEP_NAME}] no opensourceConfiguration files provided: ",
|
2018-06-01 12:33:06 +02:00
|
|
|
config.stashIncludes.get('opensourceConfiguration'),
|
|
|
|
config.stashExcludes.get('opensourceConfiguration')
|
2018-05-30 12:00:13 +02:00
|
|
|
)
|
|
|
|
//store pipeline configuration including additional groovy test scripts for future use
|
|
|
|
utils.stashWithMessage(
|
|
|
|
'pipelineConfigAndTests',
|
2018-11-20 17:03:07 +02:00
|
|
|
"[${STEP_NAME}] no pipeline configuration and test files found: ",
|
2018-05-30 12:00:13 +02:00
|
|
|
config.stashIncludes.pipelineConfigAndTests,
|
|
|
|
config.stashExcludes.pipelineConfigAndTests
|
|
|
|
)
|
|
|
|
utils.stashWithMessage(
|
|
|
|
'securityDescriptor',
|
2018-11-20 17:03:07 +02:00
|
|
|
"[${STEP_NAME}] no security descriptor found: ",
|
2018-05-30 12:00:13 +02:00
|
|
|
config.stashIncludes.securityDescriptor,
|
|
|
|
config.stashExcludes.securityDescriptor
|
|
|
|
)
|
2018-06-01 12:33:06 +02:00
|
|
|
//store files required for tests, e.g. Gauge, SUT, ...
|
|
|
|
utils.stashWithMessage(
|
|
|
|
'tests',
|
2018-11-20 17:03:07 +02:00
|
|
|
"[${STEP_NAME}] no files for tests provided: ",
|
2018-06-01 12:33:06 +02:00
|
|
|
config.stashIncludes.tests,
|
|
|
|
config.stashExcludes.tests
|
|
|
|
)
|
2018-05-30 12:00:13 +02:00
|
|
|
}
|
|
|
|
}
|