2018-09-21 16:55:31 +02:00
import static com . sap . piper . Prerequisites . checkScript
2019-04-02 10:13:27 +02:00
import com.sap.piper.GenerateDocumentation
2018-05-30 12:00:13 +02:00
import com.sap.piper.Utils
import com.sap.piper.ConfigurationHelper
import groovy.transform.Field
2018-11-29 10:54:05 +02:00
@Field String STEP_NAME = getClass ( ) . getName ( )
2019-04-02 10:13:27 +02:00
@Field Set GENERAL_CONFIG_KEYS = [ ]
@Field Set STEP_CONFIG_KEYS = [
/ * *
* By default certain files are excluded from stashing ( e . g . ` . git ` folder ) .
2021-09-13 13:57:04 +02:00
* Details can be found as per [ Pipeline basic step ` stash ` ] ( https: //jenkins.io/doc/pipeline/steps/workflow-basic-steps/#stash-stash-some-files-to-be-used-later-in-the-build).
2019-04-02 10:13:27 +02:00
* This parameter allows to provide a list of stash names for which the standard exclude behavior should be switched off .
* This will allow you to also stash directories like ` . git ` .
* /
'noDefaultExludes' ,
/** @see pipelineStashFiles */
'stashIncludes' ,
/** @see pipelineStashFiles */
'stashExcludes'
]
2018-05-30 12:00:13 +02:00
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
2019-04-02 10:13:27 +02:00
/ * *
* This step stashes files that are needed in other build steps ( on other nodes ) .
* /
@GenerateDocumentation
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' ) {
2020-08-26 15:32:58 +02:00
def script = checkScript ( this , parameters ) ? : this
Utils utils = parameters . juStabUtils ? : new Utils ( )
String stageName = parameters . stageName ? : env . STAGE_NAME
2018-05-30 12:00:13 +02:00
2018-10-17 11:05:20 +02:00
Map config = ConfigurationHelper . newInstance ( this )
2020-08-26 15:32:58 +02:00
. loadStepDefaults ( [ : ] , stageName )
2018-05-30 12:00:13 +02:00
. mixinGeneralConfig ( script . commonPipelineEnvironment , STEP_CONFIG_KEYS )
. mixinStepConfig ( script . commonPipelineEnvironment , STEP_CONFIG_KEYS )
2020-08-26 15:32:58 +02:00
. mixinStageConfig ( script . commonPipelineEnvironment , stageName , STEP_CONFIG_KEYS )
2018-05-30 12:00:13 +02:00
. mixin ( parameters , PARAMETER_KEYS )
. use ( )
2019-04-02 13:13:25 +02:00
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
}
}
}