mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Merge pull request #317 from marcusholl/pr/condenceCMCoding
condence cm coding
This commit is contained in:
commit
a405e7e82c
@ -4,6 +4,68 @@ import com.cloudbees.groovy.cps.NonCPS
|
||||
|
||||
public class StepHelpers {
|
||||
|
||||
@NonCPS
|
||||
public static def getTransportRequestId(ChangeManagement cm, def step, Map configuration) {
|
||||
|
||||
def transportRequestId = configuration.transportRequestId
|
||||
|
||||
if(transportRequestId?.trim()) {
|
||||
|
||||
step.echo "[INFO] Transport request id '${transportRequestId}' retrieved from parameters."
|
||||
|
||||
} else {
|
||||
|
||||
step.echo "[INFO] Retrieving transport request id from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
" Searching for pattern '${configuration.changeManagement.transportRequestLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
transportRequestId = cm.getTransportRequestId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.transportRequestLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
step.echo "[INFO] Transport request id '${transportRequestId}' retrieved from commit history"
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
step.echo "[WARN] Cannot retrieve transportRequestId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
return transportRequestId
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
public static getChangeDocumentId(ChangeManagement cm, def step, Map configuration) {
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
if(changeDocumentId?.trim()) {
|
||||
|
||||
step.echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
|
||||
} else {
|
||||
|
||||
step.echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeManagement.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.changeDocumentLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
step.echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
step.echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
return changeDocumentId
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
static BackendType getBackendTypeAndLogInfoIfCMIntegrationDisabled(def step, Map configuration) {
|
||||
|
||||
|
@ -11,6 +11,7 @@ import com.sap.piper.cm.BackendType
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
import static com.sap.piper.cm.StepHelpers.getChangeDocumentId
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
@Field def STEP_NAME = 'checkChangeInDevelopment'
|
||||
@ -93,37 +94,10 @@ void call(parameters = [:]) {
|
||||
*/
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
|
||||
|
||||
configuration = configHelper.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
def changeId = configuration.changeDocumentId
|
||||
|
||||
if(changeId?.trim()) {
|
||||
|
||||
echo "[INFO] ChangeDocumentId retrieved from parameters."
|
||||
|
||||
} else {
|
||||
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeManagement.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
changeId = cm.getChangeDocumentId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.changeDocumentLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
if(changeId?.trim()) {
|
||||
echo "[INFO] ChangeDocumentId '${changeId}' retrieved from commit history"
|
||||
}
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
def changeId = getChangeDocumentId(cm, this, configuration)
|
||||
|
||||
configuration = configHelper.mixin([changeDocumentId: changeId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
|
||||
@ -142,7 +116,6 @@ void call(parameters = [:]) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
isInDevelopment = cm.isChangeInDevelopment(configuration.changeDocumentId,
|
||||
configuration.changeManagement.endpoint,
|
||||
configuration.changeManagement.credentialsId,
|
||||
|
@ -10,6 +10,7 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
import static com.sap.piper.cm.StepHelpers.getChangeDocumentId
|
||||
import hudson.AbortException
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestCreate'
|
||||
@ -67,31 +68,8 @@ def call(parameters = [:]) {
|
||||
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
|
||||
changeDocumentId = configuration.changeDocumentId
|
||||
changeDocumentId = getChangeDocumentId(cm, this, configuration)
|
||||
|
||||
if(changeDocumentId?.trim()) {
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
|
||||
} else {
|
||||
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.changeDocumentLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
configHelper.mixin([changeDocumentId: changeDocumentId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
.withMandatoryProperty('developmentSystemId')
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
|
@ -10,6 +10,8 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
import static com.sap.piper.cm.StepHelpers.getTransportRequestId
|
||||
import static com.sap.piper.cm.StepHelpers.getChangeDocumentId
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestRelease'
|
||||
@ -59,61 +61,12 @@ void call(parameters = [:]) {
|
||||
new Utils().pushToSWA([step: STEP_NAME,
|
||||
stepParam1: parameters?.script == null], configuration)
|
||||
|
||||
def transportRequestId = configuration.transportRequestId
|
||||
|
||||
if(transportRequestId?.trim()) {
|
||||
|
||||
echo "[INFO] Transport request id '${transportRequestId}' retrieved from parameters."
|
||||
|
||||
} else {
|
||||
|
||||
echo "[INFO] Retrieving transport request id from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
" Searching for pattern '${configuration.gitTransportRequestLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
transportRequestId = cm.getTransportRequestId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.transportRequestLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
echo "[INFO] Transport request id '${transportRequestId}' retrieved from commit history"
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve transportRequestId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
|
||||
def changeDocumentId = null
|
||||
def transportRequestId = getTransportRequestId(cm, this, configuration)
|
||||
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
|
||||
changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
if(changeDocumentId?.trim()) {
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
|
||||
} else {
|
||||
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.changeDocumentLabel,
|
||||
configuration.changeManagement.gitformat
|
||||
)
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
changeDocumentId = getChangeDocumentId(cm, this, configuration)
|
||||
|
||||
configHelper.mixin([changeDocumentId: changeDocumentId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
|
@ -10,6 +10,8 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
import static com.sap.piper.cm.StepHelpers.getTransportRequestId
|
||||
import static com.sap.piper.cm.StepHelpers.getChangeDocumentId
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestUploadFile'
|
||||
@ -66,59 +68,10 @@ void call(parameters = [:]) {
|
||||
def changeDocumentId = null
|
||||
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
|
||||
changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
if(changeDocumentId?.trim()) {
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
|
||||
} else {
|
||||
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeManagement.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.changeDocumentLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
changeDocumentId = getChangeDocumentId(cm, this, configuration)
|
||||
}
|
||||
|
||||
def transportRequestId = configuration.transportRequestId
|
||||
|
||||
if(transportRequestId?.trim()) {
|
||||
|
||||
echo "[INFO] Transport request id '${transportRequestId}' retrieved from parameters."
|
||||
|
||||
} else {
|
||||
|
||||
echo "[INFO] Retrieving transport request id from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
" Searching for pattern '${configuration.changeManagement.transportRequestLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
transportRequestId = cm.getTransportRequestId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.transportRequestLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
echo "[INFO] Transport request id '${transportRequestId}' retrieved from commit history"
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve transportRequestId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
def transportRequestId = getTransportRequestId(cm, this, configuration)
|
||||
|
||||
configHelper
|
||||
.mixin([changeDocumentId: changeDocumentId?.trim() ?: null,
|
||||
|
Loading…
Reference in New Issue
Block a user