mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
58 lines
2.3 KiB
Groovy
58 lines
2.3 KiB
Groovy
import groovy.transform.Field
|
|
import com.sap.piper.Utils
|
|
import com.sap.piper.ConfigurationHelper
|
|
|
|
import static com.sap.piper.Prerequisites.checkScript
|
|
|
|
@Field String STEP_NAME = getClass().getName()
|
|
@Field Set GENERAL_CONFIG_KEYS = []
|
|
@Field STAGE_STEP_KEYS = [
|
|
/** Pulls Software Components / Git repositories into the ABAP Environment instance */
|
|
'abapEnvironmentPullGitRepo',
|
|
/** Checks out a Branch in the pulled Software Component on the ABAP Environment instance */
|
|
'abapEnvironmentCheckoutBranch',
|
|
/** Clones Software Components / Git repositories into the ABAP Environment instance and checks out the respective branches */
|
|
'abapEnvironmentCloneGitRepo',
|
|
/** Specifies the strategy that should be peformed on the ABAP Environment instance*/
|
|
'strategy'
|
|
]
|
|
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
|
|
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
|
/**
|
|
* This stage clones Git repositories / software components to the ABAP Environment instance and checks out the master branch
|
|
*/
|
|
void call(Map parameters = [:]) {
|
|
def script = checkScript(this, parameters) ?: this
|
|
def stageName = parameters.stageName?:env.STAGE_NAME
|
|
|
|
Map config = ConfigurationHelper.newInstance(this)
|
|
.loadStepDefaults()
|
|
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
|
|
.mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS)
|
|
.mixin(parameters, PARAMETER_KEYS)
|
|
.addIfEmpty('strategy', 'Pull')
|
|
.use()
|
|
|
|
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
|
|
switch (config.strategy) {
|
|
case 'Pull':
|
|
abapEnvironmentPullGitRepo script: parameters.script
|
|
break
|
|
case 'Clone':
|
|
abapEnvironmentCloneGitRepo script: parameters.script
|
|
break
|
|
case 'CheckoutPull':
|
|
abapEnvironmentCheckoutBranch script: parameters.script
|
|
abapEnvironmentPullGitRepo script: parameters.script
|
|
break
|
|
case 'AddonBuild':
|
|
abapEnvironmentCloneGitRepo script: parameters.script
|
|
break
|
|
default:
|
|
abapEnvironmentPullGitRepo script: parameters.script
|
|
break
|
|
}
|
|
}
|
|
|
|
}
|