2018-06-20 11:52:11 +02:00
|
|
|
import com.sap.piper.GitUtils
|
|
|
|
import groovy.transform.Field
|
|
|
|
|
2018-07-06 09:05:26 +02:00
|
|
|
import com.sap.piper.ConfigurationHelper
|
2018-06-20 11:52:11 +02:00
|
|
|
import com.sap.piper.ConfigurationMerger
|
|
|
|
import com.sap.piper.cm.ChangeManagement
|
|
|
|
import com.sap.piper.cm.ChangeManagementException
|
|
|
|
|
|
|
|
import hudson.AbortException
|
|
|
|
|
|
|
|
|
|
|
|
@Field def STEP_NAME = 'transportRequestRelease'
|
|
|
|
|
|
|
|
@Field Set stepConfigurationKeys = [
|
2018-07-17 09:21:56 +02:00
|
|
|
'changeManagement'
|
2018-06-20 11:52:11 +02:00
|
|
|
]
|
|
|
|
|
2018-07-12 09:49:18 +02:00
|
|
|
@Field Set parameterKeys = stepConfigurationKeys.plus([
|
|
|
|
'changeDocumentId',
|
|
|
|
'transportRequestId',
|
|
|
|
])
|
|
|
|
|
2018-07-06 09:05:26 +02:00
|
|
|
@Field Set generalConfigurationKeys = stepConfigurationKeys
|
|
|
|
|
2018-06-20 11:52:11 +02:00
|
|
|
def call(parameters = [:]) {
|
|
|
|
|
|
|
|
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
|
|
|
|
|
|
|
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
|
|
|
|
|
|
|
ChangeManagement cm = new ChangeManagement(script)
|
|
|
|
|
2018-07-06 09:05:26 +02:00
|
|
|
Map configuration = ConfigurationHelper
|
|
|
|
.loadStepDefaults(this)
|
|
|
|
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
|
|
|
|
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
|
|
|
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
|
|
|
.mixin(parameters, parameterKeys)
|
2018-07-12 08:54:04 +02:00
|
|
|
.withMandatoryProperty('changeDocumentId')
|
|
|
|
.withMandatoryProperty('transportRequestId')
|
2018-07-17 09:21:56 +02:00
|
|
|
.withMandatoryProperty('changeManagement/clientOpts')
|
|
|
|
.withMandatoryProperty('changeManagement/credentialsId')
|
|
|
|
.withMandatoryProperty('changeManagement/endpoint')
|
2018-07-06 09:05:26 +02:00
|
|
|
.use()
|
2018-06-20 11:52:11 +02:00
|
|
|
|
2018-07-12 08:54:04 +02:00
|
|
|
echo "[INFO] Closing transport request '${configuration.transportRequestId}' for change document '${configuration.changeDocumentId}'."
|
2018-06-20 11:52:11 +02:00
|
|
|
|
|
|
|
withCredentials([usernamePassword(
|
2018-07-17 09:21:56 +02:00
|
|
|
credentialsId: configuration.changeManagement.credentialsId,
|
2018-06-20 11:52:11 +02:00
|
|
|
passwordVariable: 'password',
|
|
|
|
usernameVariable: 'username')]) {
|
|
|
|
|
|
|
|
try {
|
2018-07-12 08:54:04 +02:00
|
|
|
cm.releaseTransportRequest(configuration.changeDocumentId,
|
|
|
|
configuration.transportRequestId,
|
2018-07-17 09:21:56 +02:00
|
|
|
configuration.changeManagement.endpoint,
|
2018-07-12 08:54:04 +02:00
|
|
|
username,
|
|
|
|
password,
|
2018-07-17 09:21:56 +02:00
|
|
|
configuration.changeManagement.clientOpts)
|
2018-06-20 11:52:11 +02:00
|
|
|
} catch(ChangeManagementException ex) {
|
|
|
|
throw new AbortException(ex.getMessage())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-12 08:54:04 +02:00
|
|
|
echo "[INFO] Transport Request '${configuration.transportRequestId}' has been successfully closed."
|
2018-06-20 11:52:11 +02:00
|
|
|
}
|
|
|
|
}
|