2020-10-02 17:03:43 +02:00
|
|
|
import groovy.transform.Field
|
2022-06-15 14:57:28 +02:00
|
|
|
import com.cloudbees.groovy.cps.NonCPS
|
|
|
|
import com.sap.piper.GenerateStageDocumentation
|
|
|
|
import groovy.transform.Field
|
2020-10-02 17:03:43 +02:00
|
|
|
import com.sap.piper.Utils
|
2022-06-15 14:57:28 +02:00
|
|
|
import com.sap.piper.ConfigurationHelper
|
|
|
|
import com.sap.piper.ConfigurationLoader
|
2020-10-02 17:03:43 +02:00
|
|
|
|
|
|
|
import static com.sap.piper.Prerequisites.checkScript
|
|
|
|
|
|
|
|
@Field String STEP_NAME = getClass().getName()
|
|
|
|
@Field Set GENERAL_CONFIG_KEYS = []
|
|
|
|
@Field STAGE_STEP_KEYS = [
|
|
|
|
'cloudFoundryCreateServiceKey',
|
|
|
|
'abapEnvironmentAssemblePackages',
|
2022-06-15 14:57:28 +02:00
|
|
|
'abapEnvironmentBuild',
|
2020-10-02 17:03:43 +02:00
|
|
|
'abapAddonAssemblyKitRegisterPackages',
|
|
|
|
'abapAddonAssemblyKitReleasePackages',
|
2021-10-28 11:01:16 +02:00
|
|
|
'abapEnvironmentAssembleConfirm',
|
2020-10-02 17:03:43 +02:00
|
|
|
'abapAddonAssemblyKitCreateTargetVector',
|
2022-06-15 14:57:28 +02:00
|
|
|
'abapAddonAssemblyKitPublishTargetVector',
|
2022-11-22 12:10:10 +02:00
|
|
|
'host', // Parameter for host config
|
|
|
|
'testBuild', // Parameter for test execution mode, if true stage will be skipped
|
2022-10-12 10:20:13 +02:00
|
|
|
'generateTagForAddonProductVersion',
|
|
|
|
'generateTagForAddonComponentVersion'
|
2020-10-02 17:03:43 +02:00
|
|
|
]
|
|
|
|
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
|
|
|
|
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
|
|
|
/**
|
2022-11-29 10:52:23 +02:00
|
|
|
* This stage builds an AddOn for the SAP BTP ABAP Environment
|
2020-10-02 17:03:43 +02:00
|
|
|
*/
|
|
|
|
void call(Map parameters = [:]) {
|
|
|
|
def script = checkScript(this, parameters) ?: this
|
|
|
|
def stageName = parameters.stageName?:env.STAGE_NAME
|
|
|
|
|
2022-06-15 14:57:28 +02:00
|
|
|
// load default & individual configuration
|
|
|
|
Map config = ConfigurationHelper.newInstance(this)
|
|
|
|
.loadStepDefaults([:], stageName)
|
|
|
|
.mixin(ConfigurationLoader.defaultStageConfiguration(script, stageName))
|
|
|
|
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
|
|
|
|
.mixinStepConfig(script.commonPipelineEnvironment, STEP_CONFIG_KEYS)
|
|
|
|
.mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS)
|
|
|
|
.mixin(parameters, PARAMETER_KEYS)
|
2022-11-22 12:10:10 +02:00
|
|
|
.addIfEmpty('testBuild', false)
|
2022-06-15 14:57:28 +02:00
|
|
|
.use()
|
|
|
|
|
2020-10-02 17:03:43 +02:00
|
|
|
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
|
2022-06-15 14:57:28 +02:00
|
|
|
if (!config.host) {
|
|
|
|
cloudFoundryCreateServiceKey script: parameters.script
|
|
|
|
}
|
2020-10-02 17:03:43 +02:00
|
|
|
abapEnvironmentAssemblePackages script: parameters.script
|
2022-05-23 13:47:03 +02:00
|
|
|
abapEnvironmentBuild(script: parameters.script, phase: 'GENERATION', downloadAllResultFiles: true, useFieldsOfAddonDescriptor: '[{"use":"Name","renameTo":"SWC"}]')
|
2020-10-02 17:03:43 +02:00
|
|
|
abapAddonAssemblyKitRegisterPackages script: parameters.script
|
2022-11-22 12:10:10 +02:00
|
|
|
if (!config.testBuild) { //Skip final steps which can hardly be undone in test mode #1
|
|
|
|
abapAddonAssemblyKitReleasePackages script: parameters.script
|
|
|
|
abapEnvironmentAssembleConfirm script: parameters.script
|
|
|
|
} else {
|
|
|
|
echo "abapAddonAssemblyKitReleasePackages skipped as testBuild = true"
|
|
|
|
echo "abapEnvironmentAssembleConfirm skipped as testBuild = true"
|
|
|
|
}
|
2020-10-02 17:03:43 +02:00
|
|
|
abapAddonAssemblyKitCreateTargetVector script: parameters.script
|
2022-11-22 12:10:10 +02:00
|
|
|
if (!config.testBuild) { //Skip final steps which can hardly be undone in test mode #2
|
|
|
|
abapAddonAssemblyKitPublishTargetVector(script: parameters.script, targetVectorScope: 'T')
|
|
|
|
if (config.generateTagForAddonComponentVersion || config.generateTagForAddonProductVersion) {
|
|
|
|
try {
|
|
|
|
Set keys = [ 'cfServiceKeyName' ]
|
|
|
|
Map configClone = ConfigurationHelper.newInstance(this)
|
|
|
|
.mixin(ConfigurationLoader.defaultStageConfiguration(script, 'Clone Repositories'))
|
|
|
|
.mixinGeneralConfig(script.commonPipelineEnvironment, keys)
|
|
|
|
.mixinStepConfig(script.commonPipelineEnvironment, keys)
|
|
|
|
.mixinStageConfig(script.commonPipelineEnvironment, 'Clone Repositories', keys)
|
|
|
|
.mixin(parameters, keys)
|
|
|
|
.use()
|
|
|
|
abapEnvironmentCreateTag(script: parameters.script, cfServiceKeyName: configClone.cfServiceKeyName)
|
|
|
|
} catch (e) {
|
|
|
|
echo 'Tag creation failed: ' + e.message
|
|
|
|
}
|
2022-10-12 10:20:13 +02:00
|
|
|
}
|
2022-11-22 12:10:10 +02:00
|
|
|
} else {
|
|
|
|
echo "abapAddonAssemblyKitPublishTargetVector skipped as testBuild = true"
|
|
|
|
echo "abapEnvironmentCreateTag skipped as testBuild = true"
|
2022-10-12 10:20:13 +02:00
|
|
|
}
|
2020-10-02 17:03:43 +02:00
|
|
|
}
|
|
|
|
}
|