mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
d8dca885bb
the official term in SAP-SolutionManager is 'change document'. The term 'change' as reflected in 'changeId' is ambigous and could also be understand in the sense of a change in a revision control system. Choosing appropriate terms for parameters here deceases the amount of documentation required for explaining what is really denoted by the parameter.
66 lines
2.3 KiB
Groovy
66 lines
2.3 KiB
Groovy
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 = 'transportRequestRelease'
|
|
|
|
@Field Set parameterKeys = [
|
|
'changeDocumentId',
|
|
'transportRequestId',
|
|
'cmCredentialsId',
|
|
'cmEndpoint'
|
|
]
|
|
|
|
@Field Set stepConfigurationKeys = [
|
|
'cmCredentialsId',
|
|
'cmEndpoint'
|
|
]
|
|
|
|
def call(parameters = [:]) {
|
|
|
|
handlePipelineStepErrors (stepName: STEP_NAME, stepParameters: parameters) {
|
|
|
|
def script = parameters?.script ?: [commonPipelineEnvironment: commonPipelineEnvironment]
|
|
|
|
ChangeManagement cm = new ChangeManagement(script)
|
|
|
|
Map configuration = ConfigurationMerger.merge(script, STEP_NAME,
|
|
parameters, parameterKeys,
|
|
stepConfigurationKeys)
|
|
|
|
def changeDocumentId = configuration.changeDocumentId
|
|
if(!changeDocumentId) throw new AbortException("Change document id not provided (parameter: 'changeDocumentId').")
|
|
|
|
def transportRequestId = configuration.transportRequestId
|
|
if(!transportRequestId) throw new AbortException("Transport Request id not provided (parameter: 'transportRequestId').")
|
|
|
|
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').")
|
|
|
|
echo "[INFO] Closing transport request '$transportRequestId' for change document '$changeDocumentId'."
|
|
|
|
withCredentials([usernamePassword(
|
|
credentialsId: cmCredentialsId,
|
|
passwordVariable: 'password',
|
|
usernameVariable: 'username')]) {
|
|
|
|
try {
|
|
cm.releaseTransportRequest(changeDocumentId, transportRequestId, cmEndpoint, username, password)
|
|
} catch(ChangeManagementException ex) {
|
|
throw new AbortException(ex.getMessage())
|
|
}
|
|
}
|
|
|
|
echo "[INFO] Transport Request '${transportRequestId}' has been successfully closed."
|
|
}
|
|
}
|