2019-02-05 16:37:59 +02:00
|
|
|
import com.sap.piper.ConfigurationHelper
|
2019-07-03 10:13:26 +02:00
|
|
|
import com.sap.piper.GenerateStageDocumentation
|
2019-02-05 16:37:59 +02:00
|
|
|
import com.sap.piper.Utils
|
|
|
|
import groovy.transform.Field
|
|
|
|
|
|
|
|
import static com.sap.piper.Prerequisites.checkScript
|
|
|
|
|
|
|
|
@Field String STEP_NAME = getClass().getName()
|
|
|
|
|
|
|
|
@Field Set GENERAL_CONFIG_KEYS = []
|
2019-07-03 10:13:26 +02:00
|
|
|
@Field STAGE_STEP_KEYS = [
|
|
|
|
/** For Docker builds: pushes the Docker image to a container registry. */
|
|
|
|
'containerPushToRegistry',
|
|
|
|
]
|
|
|
|
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
|
2019-02-05 16:37:59 +02:00
|
|
|
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
|
|
|
|
2019-07-03 10:13:26 +02:00
|
|
|
/**
|
|
|
|
* This stage is responsible to promote build artifacts to an artifact repository / container registry where they can be used from in production deployments.<br />
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@GenerateStageDocumentation(defaultStageName = 'Promote')
|
2019-02-05 16:37:59 +02:00
|
|
|
void call(Map parameters = [:]) {
|
|
|
|
|
|
|
|
def script = checkScript(this, parameters) ?: this
|
|
|
|
def utils = parameters.juStabUtils ?: new Utils()
|
|
|
|
|
|
|
|
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)
|
2019-07-03 10:13:26 +02:00
|
|
|
.addIfEmpty('containerPushToRegistry', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.containerPushToRegistry)
|
2019-02-05 16:37:59 +02:00
|
|
|
.use()
|
|
|
|
|
|
|
|
piperStageWrapper (script: script, stageName: stageName) {
|
|
|
|
|
|
|
|
// telemetry reporting
|
|
|
|
utils.pushToSWA([step: STEP_NAME], config)
|
|
|
|
|
2019-07-03 10:13:26 +02:00
|
|
|
durationMeasure(script: script, measurementName: 'promote_duration') {
|
|
|
|
if(config.containerPushToRegistry) {
|
|
|
|
containerPushToRegistry script: script
|
|
|
|
}
|
|
|
|
}
|
2019-02-05 16:37:59 +02:00
|
|
|
}
|
|
|
|
}
|