2018-06-20 11:36:41 +02:00
|
|
|
import com.sap.piper.GitUtils
|
|
|
|
import groovy.transform.Field
|
|
|
|
|
|
|
|
import com.sap.piper.ConfigurationMerger
|
|
|
|
import com.sap.piper.cm.ChangeManagement
|
|
|
|
import com.sap.piper.cm.ChangeManagementException
|
|
|
|
|
|
|
|
import hudson.AbortException
|
|
|
|
|
|
|
|
|
|
|
|
@Field def STEP_NAME = 'transportRequestCreate'
|
|
|
|
|
|
|
|
@Field Set parameterKeys = [
|
2018-06-28 08:46:23 +02:00
|
|
|
'changeDocumentId',
|
2018-06-20 11:36:41 +02:00
|
|
|
'developmentSystemId',
|
|
|
|
'cmCredentialsId',
|
|
|
|
'cmEndpoint'
|
|
|
|
]
|
|
|
|
|
|
|
|
@Field Set stepConfigurationKeys = [
|
|
|
|
'cmCredentialsId',
|
|
|
|
'cmEndpoint'
|
|
|
|
]
|
|
|
|
|
|
|
|
def call(parameters = [:]) {
|
|
|
|
|
|
|
|
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
|
|
|
|
|
|
|
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
|
|
|
|
2018-06-29 09:34:46 +02:00
|
|
|
ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script)
|
2018-06-20 11:36:41 +02:00
|
|
|
|
|
|
|
Map configuration = ConfigurationMerger.merge(parameters.script, STEP_NAME,
|
|
|
|
parameters, parameterKeys,
|
|
|
|
stepConfigurationKeys)
|
|
|
|
|
2018-06-28 08:46:23 +02:00
|
|
|
def changeDocumentId = configuration.changeDocumentId
|
|
|
|
if(!changeDocumentId) throw new AbortException('Change document id not provided (parameter: \'changeDocumentId\').')
|
2018-06-20 11:36:41 +02:00
|
|
|
|
|
|
|
def developmentSystemId = configuration.developmentSystemId
|
|
|
|
if(!developmentSystemId) throw new AbortException('Development system id not provided (parameter: \'developmentSystemId\').')
|
|
|
|
|
|
|
|
def cmCredentialsId = configuration.cmCredentialsId
|
|
|
|
if(!cmCredentialsId) throw new AbortException('Credentials id not provided (parameter: \'cmCredentialsId\').')
|
|
|
|
|
|
|
|
def cmEndpoint = configuration.cmEndpoint
|
|
|
|
if(!cmEndpoint) throw new AbortException('Solution Manager endpoint not provided (parameter: \'cmEndpoint\').')
|
|
|
|
|
|
|
|
def transportRequestId
|
|
|
|
|
2018-06-28 08:46:23 +02:00
|
|
|
echo "[INFO] Creating transport request for change document '$changeDocumentId' and development system '$developmentSystemId'."
|
2018-06-20 11:36:41 +02:00
|
|
|
|
|
|
|
withCredentials([usernamePassword(
|
|
|
|
credentialsId: cmCredentialsId,
|
|
|
|
passwordVariable: 'password',
|
|
|
|
usernameVariable: 'username')]) {
|
|
|
|
|
|
|
|
try {
|
2018-06-28 08:46:23 +02:00
|
|
|
transportRequestId = cm.createTransportRequest(changeDocumentId, developmentSystemId, cmEndpoint, username, password)
|
2018-06-20 11:36:41 +02:00
|
|
|
} catch(ChangeManagementException ex) {
|
|
|
|
throw new AbortException(ex.getMessage())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "[INFO] Transport Request '$transportRequestId' has been successfully created."
|
|
|
|
return transportRequestId
|
|
|
|
}
|
|
|
|
}
|