mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-20 05:19:40 +02:00
Condence common code for cm scenario
This commit is contained in:
parent
ced73231fa
commit
058c6c0d9a
37
src/com/sap/piper/cm/StepHelpers.groovy
Normal file
37
src/com/sap/piper/cm/StepHelpers.groovy
Normal file
@ -0,0 +1,37 @@
|
||||
package com.sap.piper.cm;
|
||||
|
||||
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
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
import static com.sap.piper.cm.StepHelpers.getTransportRequestId
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestRelease'
|
||||
|
||||
@ -48,31 +49,7 @@ def call(parameters = [:]) {
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], 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 transportRequestId = getTransportRequestId(cm, this, configuration)
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
|
@ -9,6 +9,7 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
import static com.sap.piper.cm.StepHelpers.getTransportRequestId
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestUploadFile'
|
||||
|
||||
@ -80,31 +81,7 @@ def call(parameters = [:]) {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
configuration = configHelper
|
||||
.mixin([changeDocumentId: changeDocumentId?.trim() ?: null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user