mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-03-03 15:02:35 +02:00
changeId is removed from the step parameters since the changeId is specific to the build. Hence there is no reason for providing it from the deeper configuration layers.
72 lines
2.9 KiB
Groovy
72 lines
2.9 KiB
Groovy
import com.sap.piper.GitUtils
|
|
import groovy.transform.Field
|
|
|
|
import com.sap.piper.ConfigurationHelper
|
|
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 stepConfigurationKeys = [
|
|
'credentialsId',
|
|
'clientOpts',
|
|
'endpoint'
|
|
]
|
|
|
|
@Field Set parameterKeys = stepConfigurationKeys.plus(['changeDocumentId', 'developmentSystemId'])
|
|
|
|
@Field generalConfigurationKeys = stepConfigurationKeys
|
|
|
|
def call(parameters = [:]) {
|
|
|
|
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
|
|
|
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
|
|
|
ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script)
|
|
|
|
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)
|
|
.use()
|
|
|
|
def changeDocumentId = configuration.changeDocumentId
|
|
if(!changeDocumentId) throw new AbortException('Change document id not provided (parameter: \'changeDocumentId\').')
|
|
|
|
def developmentSystemId = configuration.developmentSystemId
|
|
if(!developmentSystemId) throw new AbortException('Development system id not provided (parameter: \'developmentSystemId\').')
|
|
|
|
def credentialsId = configuration.credentialsId
|
|
if(!credentialsId) throw new AbortException('Credentials id not provided (parameter: \'credentialsId\').')
|
|
|
|
def endpoint = configuration.endpoint
|
|
if(!endpoint) throw new AbortException('Solution Manager endpoint not provided (parameter: \'endpoint\').')
|
|
|
|
def transportRequestId
|
|
|
|
echo "[INFO] Creating transport request for change document '$changeDocumentId' and development system '$developmentSystemId'."
|
|
|
|
withCredentials([usernamePassword(
|
|
credentialsId: credentialsId,
|
|
passwordVariable: 'password',
|
|
usernameVariable: 'username')]) {
|
|
|
|
try {
|
|
transportRequestId = cm.createTransportRequest(changeDocumentId, developmentSystemId, endpoint, username, password, configuration.clientOpts)
|
|
} catch(ChangeManagementException ex) {
|
|
throw new AbortException(ex.getMessage())
|
|
}
|
|
}
|
|
|
|
echo "[INFO] Transport Request '$transportRequestId' has been successfully created."
|
|
return transportRequestId
|
|
}
|
|
}
|