mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
Merge remote-tracking branch 'github/master' into HEAD
This commit is contained in:
commit
b72cb656d5
@ -95,7 +95,7 @@ steps:
|
||||
newmanCollection: '**/*.postman_collection.json'
|
||||
newmanEnvironment: ''
|
||||
newmanGlobals: ''
|
||||
newmanRunCommand: "run ${config.newmanCollection} --environment '${config.newmanEnvironment}' --globals '${config.newmanGlobals}' --reporters junit,html --reporter-junit-export target/newman/TEST-${config.newmanCollection.toString().replace(File.separatorChar,(char)'_').tokenize('.').first()}.xml --reporter-html-export target/newman/TEST-${config.newmanCollection.toString().replace(File.separatorChar,(char)'_').tokenize('.').first()}.html"
|
||||
newmanRunCommand: "run ${config.newmanCollection} --environment '${config.newmanEnvironment}' --globals '${config.newmanGlobals}' --reporters junit,html --reporter-junit-export target/newman/TEST-${collectionDisplayName}.xml --reporter-html-export target/newman/TEST-${collectionDisplayName}.html"
|
||||
pipelineStashFilesAfterBuild:
|
||||
runOpaTests: false
|
||||
stashIncludes:
|
||||
|
@ -134,8 +134,10 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
@Test
|
||||
public void nullChangeDocumentIdTest() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("ChangeId is null or empty.")
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("No changeDocumentId provided. Neither via parameter 'changeDocumentId' " +
|
||||
"nor via label 'configuration.gitChangeIdLabel' in commit range " +
|
||||
"[from: origin/master, to: HEAD].")
|
||||
|
||||
ChangeManagement cm = getChangeManagementUtils(false, null)
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
@ -146,8 +148,10 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
@Test
|
||||
public void emptyChangeDocumentIdTest() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("ChangeId is null or empty.")
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("No changeDocumentId provided. Neither via parameter 'changeDocumentId' " +
|
||||
"nor via label 'configuration.gitChangeIdLabel' in commit range " +
|
||||
"[from: origin/master, to: HEAD].")
|
||||
|
||||
ChangeManagement cm = getChangeManagementUtils(false, '')
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
|
@ -61,6 +61,8 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
@Test
|
||||
public void changeIdNotProvidedTest() {
|
||||
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId' or via commit history).")
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
String getChangeDocumentId(
|
||||
String from,
|
||||
@ -72,17 +74,14 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
}
|
||||
}
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId' or via commit history).")
|
||||
|
||||
jsr.step.call(script: nullScript, developmentSystemId: '001', cmUtils: cm)
|
||||
}
|
||||
|
||||
@Test
|
||||
public void developmentSystemIdNotProvidedTest() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Development system id not provided (parameter: 'developmentSystemId').")
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR developmentSystemId")
|
||||
|
||||
jsr.step.call(script: nullScript, changeDocumentId: '001')
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ public class TransportRequestReleaseTest extends BasePiperTest {
|
||||
@Test
|
||||
public void changeIdNotProvidedTest() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId').")
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR changeDocumentId")
|
||||
|
||||
jsr.step.call(script: nullScript, transportRequestId: '001')
|
||||
}
|
||||
@ -66,8 +66,8 @@ public class TransportRequestReleaseTest extends BasePiperTest {
|
||||
@Test
|
||||
public void transportRequestIdNotProvidedTest() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Transport Request id not provided (parameter: 'transportRequestId').")
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR transportRequestId")
|
||||
|
||||
jsr.step.call(script: nullScript, changeDocumentId: '001')
|
||||
}
|
||||
|
@ -60,6 +60,9 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
@Test
|
||||
public void changeDocumentIdNotProvidedTest() {
|
||||
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId' or via commit history).")
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
String getChangeDocumentId(
|
||||
String from,
|
||||
@ -71,9 +74,6 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
}
|
||||
}
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId' or via commit history).")
|
||||
|
||||
jsr.step.call(script: nullScript, transportRequestId: '001', applicationId: 'app', filePath: '/path', cmUtils: cm)
|
||||
}
|
||||
|
||||
@ -91,8 +91,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
}
|
||||
}
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Transport Request id not provided (parameter: 'transportRequestId' or via commit history).")
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("Transport request id not provided (parameter: 'transportRequestId' or via commit history).")
|
||||
|
||||
jsr.step.call(script: nullScript, changeDocumentId: '001', applicationId: 'app', filePath: '/path', cmUtils: cm)
|
||||
}
|
||||
@ -100,8 +100,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
@Test
|
||||
public void applicationIdNotProvidedTest() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("Application id not provided (parameter: 'applicationId').")
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR applicationId")
|
||||
|
||||
jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '001', filePath: '/path')
|
||||
}
|
||||
@ -109,8 +109,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
@Test
|
||||
public void filePathNotProvidedTest() {
|
||||
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage("File path not provided (parameter: 'filePath').")
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR filePath")
|
||||
|
||||
jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '001', applicationId: 'app')
|
||||
}
|
||||
|
@ -9,8 +9,7 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
@Field def STEP_NAME = 'checkChangeInDevelopment'
|
||||
|
||||
@Field Set parameterKeys = [
|
||||
'changeDocumentId',
|
||||
@Field Set stepConfigurationKeys = [
|
||||
'cmClientOpts',
|
||||
'credentialsId',
|
||||
'endpoint',
|
||||
@ -21,17 +20,7 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
'gitFormat'
|
||||
]
|
||||
|
||||
@Field Set stepConfigurationKeys = [
|
||||
'changeDocumentId',
|
||||
'cmClientOpts',
|
||||
'credentialsId',
|
||||
'endpoint',
|
||||
'failIfStatusIsNotInDevelopment',
|
||||
'gitFrom',
|
||||
'gitTo',
|
||||
'gitChangeDocumentLabel',
|
||||
'gitFormat'
|
||||
]
|
||||
@Field Set parameterKeys = stepConfigurationKeys.plus('changeDocumentId')
|
||||
|
||||
@Field Set generalConfigurationKeys = stepConfigurationKeys
|
||||
|
||||
@ -45,13 +34,14 @@ def call(parameters = [:]) {
|
||||
|
||||
ChangeManagement cm = parameters?.cmUtils ?: new ChangeManagement(script, gitUtils)
|
||||
|
||||
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()
|
||||
ConfigurationHelper configHelper = ConfigurationHelper
|
||||
.loadStepDefaults(this)
|
||||
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
def changeId = configuration.changeDocumentId
|
||||
|
||||
@ -73,17 +63,23 @@ def call(parameters = [:]) {
|
||||
)
|
||||
if(changeId?.trim()) {
|
||||
echo "[INFO] ChangeDocumentId '${changeId}' retrieved from commit history"
|
||||
} else {
|
||||
throw new ChangeManagementException("ChangeId is null or empty.")
|
||||
}
|
||||
} catch(ChangeManagementException ex) {
|
||||
throw new AbortException(ex.getMessage())
|
||||
}
|
||||
}
|
||||
|
||||
configuration = configHelper.mixin([changeDocumentId: changeId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
.withMandatoryProperty('endpoint')
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
"No changeDocumentId provided. Neither via parameter 'changeDocumentId' " +
|
||||
"nor via label 'configuration.gitChangeIdLabel' in commit range " +
|
||||
"[from: ${configuration.gitFrom}, to: ${configuration.gitTo}].")
|
||||
.use()
|
||||
|
||||
boolean isInDevelopment
|
||||
|
||||
echo "[INFO] Checking if change document '$changeId' is in development."
|
||||
echo "[INFO] Checking if change document '${configuration.changeDocumentId}' is in development."
|
||||
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: configuration.credentialsId,
|
||||
@ -91,7 +87,11 @@ def call(parameters = [:]) {
|
||||
usernameVariable: 'username')]) {
|
||||
|
||||
try {
|
||||
isInDevelopment = cm.isChangeInDevelopment(changeId, configuration.endpoint, username, password, configuration.cmClientOpts)
|
||||
isInDevelopment = cm.isChangeInDevelopment(configuration.changeDocumentId,
|
||||
configuration.endpoint,
|
||||
username,
|
||||
password,
|
||||
configuration.cmClientOpts)
|
||||
} catch(ChangeManagementException ex) {
|
||||
throw new AbortException(ex.getMessage())
|
||||
}
|
||||
|
@ -37,10 +37,14 @@ def call(Map parameters = [:]) {
|
||||
) {
|
||||
sh 'npm install newman --global --quiet'
|
||||
for(String collection : collectionList){
|
||||
def collectionDisplayName = collection.toString().replace(File.separatorChar,(char)'_').tokenize('.').first()
|
||||
// resolve templates
|
||||
def command = SimpleTemplateEngine.newInstance()
|
||||
.createTemplate(config.newmanRunCommand)
|
||||
.make([config: config.plus([newmanCollection: collection])]).toString()
|
||||
.make([
|
||||
config: config.plus([newmanCollection: collection]),
|
||||
collectionDisplayName: collectionDisplayName
|
||||
]).toString()
|
||||
if(!config.failOnError) command += ' --suppress-exit-code'
|
||||
sh "newman ${command}"
|
||||
}
|
||||
|
@ -11,18 +11,6 @@ import hudson.AbortException
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestCreate'
|
||||
|
||||
@Field Set parameterKeys = [
|
||||
'changeDocumentId',
|
||||
'clientOpts',
|
||||
'developmentSystemId',
|
||||
'credentialsId',
|
||||
'endpoint',
|
||||
'gitFrom',
|
||||
'gitTo',
|
||||
'gitChangeDocumentLabel',
|
||||
'gitFormat'
|
||||
]
|
||||
|
||||
@Field Set stepConfigurationKeys = [
|
||||
'credentialsId',
|
||||
'clientOpts',
|
||||
@ -33,6 +21,8 @@ import hudson.AbortException
|
||||
'gitFormat'
|
||||
]
|
||||
|
||||
@Field Set parameterKeys = stepConfigurationKeys.plus(['changeDocumentId', 'developmentSystemId'])
|
||||
|
||||
@Field generalConfigurationKeys = stepConfigurationKeys
|
||||
|
||||
def call(parameters = [:]) {
|
||||
@ -43,13 +33,16 @@ def call(parameters = [:]) {
|
||||
|
||||
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()
|
||||
ConfigurationHelper configHelper = ConfigurationHelper
|
||||
.loadStepDefaults(this)
|
||||
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.withMandatoryProperty('endpoint')
|
||||
.withMandatoryProperty('developmentSystemId')
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
@ -76,30 +69,27 @@ def call(parameters = [:]) {
|
||||
}
|
||||
}
|
||||
|
||||
if(! changeDocumentId?.trim()) {
|
||||
throw new AbortException("Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
|
||||
}
|
||||
|
||||
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\').')
|
||||
configuration = configHelper.mixin([changeDocumentId: changeDocumentId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
"Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
|
||||
.use()
|
||||
|
||||
def transportRequestId
|
||||
|
||||
echo "[INFO] Creating transport request for change document '$changeDocumentId' and development system '$developmentSystemId'."
|
||||
echo "[INFO] Creating transport request for change document '${configuration.changeDocumentId}' and development system '${configuration.developmentSystemId}'."
|
||||
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: credentialsId,
|
||||
credentialsId: configuration.credentialsId,
|
||||
passwordVariable: 'password',
|
||||
usernameVariable: 'username')]) {
|
||||
|
||||
try {
|
||||
transportRequestId = cm.createTransportRequest(changeDocumentId, developmentSystemId, endpoint, username, password, configuration.clientOpts)
|
||||
transportRequestId = cm.createTransportRequest(configuration.changeDocumentId,
|
||||
configuration.developmentSystemId,
|
||||
configuration.endpoint,
|
||||
username,
|
||||
password,
|
||||
configuration.clientOpts)
|
||||
} catch(ChangeManagementException ex) {
|
||||
throw new AbortException(ex.getMessage())
|
||||
}
|
||||
|
@ -11,20 +11,17 @@ import hudson.AbortException
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestRelease'
|
||||
|
||||
@Field Set parameterKeys = [
|
||||
'changeDocumentId',
|
||||
'cmClientOpts',
|
||||
'transportRequestId',
|
||||
'credentialsId',
|
||||
'endpoint'
|
||||
]
|
||||
|
||||
@Field Set stepConfigurationKeys = [
|
||||
'credentialsId',
|
||||
'cmClientOpts',
|
||||
'endpoint'
|
||||
]
|
||||
|
||||
@Field Set parameterKeys = stepConfigurationKeys.plus([
|
||||
'changeDocumentId',
|
||||
'transportRequestId',
|
||||
])
|
||||
|
||||
@Field Set generalConfigurationKeys = stepConfigurationKeys
|
||||
|
||||
def call(parameters = [:]) {
|
||||
@ -41,34 +38,30 @@ def call(parameters = [:]) {
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.withMandatoryProperty('changeDocumentId')
|
||||
.withMandatoryProperty('transportRequestId')
|
||||
.withMandatoryProperty('endpoint')
|
||||
.use()
|
||||
|
||||
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 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').")
|
||||
|
||||
echo "[INFO] Closing transport request '$transportRequestId' for change document '$changeDocumentId'."
|
||||
echo "[INFO] Closing transport request '${configuration.transportRequestId}' for change document '${configuration.changeDocumentId}'."
|
||||
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: credentialsId,
|
||||
credentialsId: configuration.credentialsId,
|
||||
passwordVariable: 'password',
|
||||
usernameVariable: 'username')]) {
|
||||
|
||||
try {
|
||||
cm.releaseTransportRequest(changeDocumentId, transportRequestId, endpoint, username, password, configuration.cmClientOpts)
|
||||
cm.releaseTransportRequest(configuration.changeDocumentId,
|
||||
configuration.transportRequestId,
|
||||
configuration.endpoint,
|
||||
username,
|
||||
password,
|
||||
configuration.cmClientOpts)
|
||||
} catch(ChangeManagementException ex) {
|
||||
throw new AbortException(ex.getMessage())
|
||||
}
|
||||
}
|
||||
|
||||
echo "[INFO] Transport Request '${transportRequestId}' has been successfully closed."
|
||||
echo "[INFO] Transport Request '${configuration.transportRequestId}' has been successfully closed."
|
||||
}
|
||||
}
|
||||
|
@ -11,21 +11,6 @@ import hudson.AbortException
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestUploadFile'
|
||||
|
||||
@Field Set parameterKeys = [
|
||||
'changeDocumentId',
|
||||
'cmClientOpts',
|
||||
'transportRequestId',
|
||||
'applicationId',
|
||||
'filePath',
|
||||
'credentialsId',
|
||||
'endpoint',
|
||||
'gitFrom',
|
||||
'gitTo',
|
||||
'gitChangeDocumentLabel',
|
||||
'gitTransportRequestLabel',
|
||||
'gitFormat'
|
||||
]
|
||||
|
||||
@Field Set generalConfigurationKeys = [
|
||||
'credentialsId',
|
||||
'cmClientOpts',
|
||||
@ -37,6 +22,12 @@ import hudson.AbortException
|
||||
'gitFormat'
|
||||
]
|
||||
|
||||
@Field Set parameterKeys = generalConfigurationKeys.plus([
|
||||
'applicationId',
|
||||
'changeDocumentId',
|
||||
'filePath',
|
||||
'transportRequestId'])
|
||||
|
||||
@Field Set stepConfigurationKeys = generalConfigurationKeys
|
||||
|
||||
def call(parameters = [:]) {
|
||||
@ -47,13 +38,17 @@ def call(parameters = [:]) {
|
||||
|
||||
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()
|
||||
ConfigurationHelper configHelper =
|
||||
ConfigurationHelper.loadStepDefaults(this)
|
||||
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.withMandatoryProperty('endpoint')
|
||||
.withMandatoryProperty('applicationId')
|
||||
.withMandatoryProperty('filePath')
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
@ -81,7 +76,6 @@ def call(parameters = [:]) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def transportRequestId = configuration.transportRequestId
|
||||
|
||||
if(transportRequestId?.trim()) {
|
||||
@ -108,38 +102,36 @@ def call(parameters = [:]) {
|
||||
}
|
||||
}
|
||||
|
||||
if(! changeDocumentId?.trim()) {
|
||||
throw new AbortException("Change document id not provided (parameter: 'changeDocumentId' or via commit history).")
|
||||
}
|
||||
configuration = configHelper
|
||||
.mixin([changeDocumentId: changeDocumentId?.trim() ?: null,
|
||||
transportRequestId: transportRequestId?.trim() ?: null], ['changeDocumentId', 'transportRequestId'] as Set)
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
"Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
|
||||
.withMandatoryProperty('transportRequestId',
|
||||
"Transport request id not provided (parameter: \'transportRequestId\' or via commit history).")
|
||||
.use()
|
||||
|
||||
if(!transportRequestId?.trim()) throw new AbortException("Transport Request id not provided (parameter: 'transportRequestId' or via commit history).")
|
||||
|
||||
def applicationId = configuration.applicationId
|
||||
if(!applicationId) throw new AbortException("Application id not provided (parameter: 'applicationId').")
|
||||
|
||||
def filePath = configuration.filePath
|
||||
if(!filePath) throw new AbortException("File path not provided (parameter: 'filePath').")
|
||||
|
||||
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').")
|
||||
|
||||
echo "[INFO] Uploading file '$filePath' to transport request '$transportRequestId' of change document '$changeDocumentId'."
|
||||
echo "[INFO] Uploading file '${configuration.filePath}' to transport request '${configuration.transportRequestId}' of change document '${configuration.changeDocumentId}'."
|
||||
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: credentialsId,
|
||||
credentialsId: configuration.credentialsId,
|
||||
passwordVariable: 'password',
|
||||
usernameVariable: 'username')]) {
|
||||
|
||||
try {
|
||||
cm.uploadFileToTransportRequest(changeDocumentId, transportRequestId, applicationId, filePath, endpoint, username, password, configuration.cmClientOpts)
|
||||
cm.uploadFileToTransportRequest(configuration.changeDocumentId,
|
||||
configuration.transportRequestId,
|
||||
configuration.applicationId,
|
||||
configuration.filePath,
|
||||
configuration.endpoint,
|
||||
username,
|
||||
password,
|
||||
configuration.cmClientOpts)
|
||||
} catch(ChangeManagementException ex) {
|
||||
throw new AbortException(ex.getMessage())
|
||||
}
|
||||
}
|
||||
|
||||
echo "[INFO] File '$filePath' has been successfully uploaded to transport request '$transportRequestId' of change document '$changeDocumentId'."
|
||||
echo "[INFO] File '${configuration.filePath}' has been successfully uploaded to transport request '${configuration.transportRequestId}' of change document '${configuration.changeDocumentId}'."
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user