1
0
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:
Marcus Holl 2018-07-16 11:04:20 +02:00
commit b72cb656d5
10 changed files with 132 additions and 150 deletions

View File

@ -95,7 +95,7 @@ steps:
newmanCollection: '**/*.postman_collection.json' newmanCollection: '**/*.postman_collection.json'
newmanEnvironment: '' newmanEnvironment: ''
newmanGlobals: '' 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: pipelineStashFilesAfterBuild:
runOpaTests: false runOpaTests: false
stashIncludes: stashIncludes:

View File

@ -134,8 +134,10 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
@Test @Test
public void nullChangeDocumentIdTest() { public void nullChangeDocumentIdTest() {
thrown.expect(AbortException) thrown.expect(IllegalArgumentException)
thrown.expectMessage("ChangeId is null or empty.") 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) ChangeManagement cm = getChangeManagementUtils(false, null)
jsr.step.checkChangeInDevelopment( jsr.step.checkChangeInDevelopment(
@ -146,8 +148,10 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
@Test @Test
public void emptyChangeDocumentIdTest() { public void emptyChangeDocumentIdTest() {
thrown.expect(AbortException) thrown.expect(IllegalArgumentException)
thrown.expectMessage("ChangeId is null or empty.") 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, '') ChangeManagement cm = getChangeManagementUtils(false, '')
jsr.step.checkChangeInDevelopment( jsr.step.checkChangeInDevelopment(

View File

@ -61,6 +61,8 @@ public class TransportRequestCreateTest extends BasePiperTest {
@Test @Test
public void changeIdNotProvidedTest() { public void changeIdNotProvidedTest() {
thrown.expect(IllegalArgumentException)
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId' or via commit history).")
ChangeManagement cm = new ChangeManagement(nullScript) { ChangeManagement cm = new ChangeManagement(nullScript) {
String getChangeDocumentId( String getChangeDocumentId(
String from, 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) jsr.step.call(script: nullScript, developmentSystemId: '001', cmUtils: cm)
} }
@Test @Test
public void developmentSystemIdNotProvidedTest() { public void developmentSystemIdNotProvidedTest() {
thrown.expect(AbortException) thrown.expect(IllegalArgumentException)
thrown.expectMessage("Development system id not provided (parameter: 'developmentSystemId').") thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR developmentSystemId")
jsr.step.call(script: nullScript, changeDocumentId: '001') jsr.step.call(script: nullScript, changeDocumentId: '001')
} }

View File

@ -57,8 +57,8 @@ public class TransportRequestReleaseTest extends BasePiperTest {
@Test @Test
public void changeIdNotProvidedTest() { public void changeIdNotProvidedTest() {
thrown.expect(AbortException) thrown.expect(IllegalArgumentException)
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId').") thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR changeDocumentId")
jsr.step.call(script: nullScript, transportRequestId: '001') jsr.step.call(script: nullScript, transportRequestId: '001')
} }
@ -66,8 +66,8 @@ public class TransportRequestReleaseTest extends BasePiperTest {
@Test @Test
public void transportRequestIdNotProvidedTest() { public void transportRequestIdNotProvidedTest() {
thrown.expect(AbortException) thrown.expect(IllegalArgumentException)
thrown.expectMessage("Transport Request id not provided (parameter: 'transportRequestId').") thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR transportRequestId")
jsr.step.call(script: nullScript, changeDocumentId: '001') jsr.step.call(script: nullScript, changeDocumentId: '001')
} }

View File

@ -60,6 +60,9 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
@Test @Test
public void changeDocumentIdNotProvidedTest() { public void changeDocumentIdNotProvidedTest() {
thrown.expect(IllegalArgumentException)
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId' or via commit history).")
ChangeManagement cm = new ChangeManagement(nullScript) { ChangeManagement cm = new ChangeManagement(nullScript) {
String getChangeDocumentId( String getChangeDocumentId(
String from, 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) 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.expect(IllegalArgumentException)
thrown.expectMessage("Transport Request id not provided (parameter: 'transportRequestId' or via commit history).") 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) jsr.step.call(script: nullScript, changeDocumentId: '001', applicationId: 'app', filePath: '/path', cmUtils: cm)
} }
@ -100,8 +100,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
@Test @Test
public void applicationIdNotProvidedTest() { public void applicationIdNotProvidedTest() {
thrown.expect(AbortException) thrown.expect(IllegalArgumentException)
thrown.expectMessage("Application id not provided (parameter: 'applicationId').") thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR applicationId")
jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '001', filePath: '/path') jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '001', filePath: '/path')
} }
@ -109,8 +109,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
@Test @Test
public void filePathNotProvidedTest() { public void filePathNotProvidedTest() {
thrown.expect(AbortException) thrown.expect(IllegalArgumentException)
thrown.expectMessage("File path not provided (parameter: 'filePath').") thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR filePath")
jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '001', applicationId: 'app') jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '001', applicationId: 'app')
} }

View File

@ -9,8 +9,7 @@ import com.sap.piper.cm.ChangeManagementException
@Field def STEP_NAME = 'checkChangeInDevelopment' @Field def STEP_NAME = 'checkChangeInDevelopment'
@Field Set parameterKeys = [ @Field Set stepConfigurationKeys = [
'changeDocumentId',
'cmClientOpts', 'cmClientOpts',
'credentialsId', 'credentialsId',
'endpoint', 'endpoint',
@ -21,17 +20,7 @@ import com.sap.piper.cm.ChangeManagementException
'gitFormat' 'gitFormat'
] ]
@Field Set stepConfigurationKeys = [ @Field Set parameterKeys = stepConfigurationKeys.plus('changeDocumentId')
'changeDocumentId',
'cmClientOpts',
'credentialsId',
'endpoint',
'failIfStatusIsNotInDevelopment',
'gitFrom',
'gitTo',
'gitChangeDocumentLabel',
'gitFormat'
]
@Field Set generalConfigurationKeys = stepConfigurationKeys @Field Set generalConfigurationKeys = stepConfigurationKeys
@ -45,13 +34,14 @@ def call(parameters = [:]) {
ChangeManagement cm = parameters?.cmUtils ?: new ChangeManagement(script, gitUtils) ChangeManagement cm = parameters?.cmUtils ?: new ChangeManagement(script, gitUtils)
Map configuration = ConfigurationHelper ConfigurationHelper configHelper = ConfigurationHelper
.loadStepDefaults(this) .loadStepDefaults(this)
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys) .mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys) .mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys) .mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
.mixin(parameters, parameterKeys) .mixin(parameters, parameterKeys)
.use()
Map configuration = configHelper.use()
def changeId = configuration.changeDocumentId def changeId = configuration.changeDocumentId
@ -73,17 +63,23 @@ def call(parameters = [:]) {
) )
if(changeId?.trim()) { if(changeId?.trim()) {
echo "[INFO] ChangeDocumentId '${changeId}' retrieved from commit history" echo "[INFO] ChangeDocumentId '${changeId}' retrieved from commit history"
} else {
throw new ChangeManagementException("ChangeId is null or empty.")
} }
} catch(ChangeManagementException ex) { } catch(ChangeManagementException ex) {
throw new AbortException(ex.getMessage()) 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 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( withCredentials([usernamePassword(
credentialsId: configuration.credentialsId, credentialsId: configuration.credentialsId,
@ -91,7 +87,11 @@ def call(parameters = [:]) {
usernameVariable: 'username')]) { usernameVariable: 'username')]) {
try { 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) { } catch(ChangeManagementException ex) {
throw new AbortException(ex.getMessage()) throw new AbortException(ex.getMessage())
} }

View File

@ -37,10 +37,14 @@ def call(Map parameters = [:]) {
) { ) {
sh 'npm install newman --global --quiet' sh 'npm install newman --global --quiet'
for(String collection : collectionList){ for(String collection : collectionList){
def collectionDisplayName = collection.toString().replace(File.separatorChar,(char)'_').tokenize('.').first()
// resolve templates // resolve templates
def command = SimpleTemplateEngine.newInstance() def command = SimpleTemplateEngine.newInstance()
.createTemplate(config.newmanRunCommand) .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' if(!config.failOnError) command += ' --suppress-exit-code'
sh "newman ${command}" sh "newman ${command}"
} }

View File

@ -11,18 +11,6 @@ import hudson.AbortException
@Field def STEP_NAME = 'transportRequestCreate' @Field def STEP_NAME = 'transportRequestCreate'
@Field Set parameterKeys = [
'changeDocumentId',
'clientOpts',
'developmentSystemId',
'credentialsId',
'endpoint',
'gitFrom',
'gitTo',
'gitChangeDocumentLabel',
'gitFormat'
]
@Field Set stepConfigurationKeys = [ @Field Set stepConfigurationKeys = [
'credentialsId', 'credentialsId',
'clientOpts', 'clientOpts',
@ -33,6 +21,8 @@ import hudson.AbortException
'gitFormat' 'gitFormat'
] ]
@Field Set parameterKeys = stepConfigurationKeys.plus(['changeDocumentId', 'developmentSystemId'])
@Field generalConfigurationKeys = stepConfigurationKeys @Field generalConfigurationKeys = stepConfigurationKeys
def call(parameters = [:]) { def call(parameters = [:]) {
@ -43,13 +33,16 @@ def call(parameters = [:]) {
ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script) ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script)
Map configuration = ConfigurationHelper ConfigurationHelper configHelper = ConfigurationHelper
.loadStepDefaults(this) .loadStepDefaults(this)
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys) .mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys) .mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys) .mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
.mixin(parameters, parameterKeys) .mixin(parameters, parameterKeys)
.use() .withMandatoryProperty('endpoint')
.withMandatoryProperty('developmentSystemId')
Map configuration = configHelper.use()
def changeDocumentId = configuration.changeDocumentId def changeDocumentId = configuration.changeDocumentId
@ -76,30 +69,27 @@ def call(parameters = [:]) {
} }
} }
if(! changeDocumentId?.trim()) { configuration = configHelper.mixin([changeDocumentId: changeDocumentId?.trim() ?: null], ['changeDocumentId'] as Set)
throw new AbortException("Change document id not provided (parameter: \'changeDocumentId\' or via commit history).") .withMandatoryProperty('changeDocumentId',
} "Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
.use()
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 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( withCredentials([usernamePassword(
credentialsId: credentialsId, credentialsId: configuration.credentialsId,
passwordVariable: 'password', passwordVariable: 'password',
usernameVariable: 'username')]) { usernameVariable: 'username')]) {
try { 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) { } catch(ChangeManagementException ex) {
throw new AbortException(ex.getMessage()) throw new AbortException(ex.getMessage())
} }

View File

@ -11,20 +11,17 @@ import hudson.AbortException
@Field def STEP_NAME = 'transportRequestRelease' @Field def STEP_NAME = 'transportRequestRelease'
@Field Set parameterKeys = [
'changeDocumentId',
'cmClientOpts',
'transportRequestId',
'credentialsId',
'endpoint'
]
@Field Set stepConfigurationKeys = [ @Field Set stepConfigurationKeys = [
'credentialsId', 'credentialsId',
'cmClientOpts', 'cmClientOpts',
'endpoint' 'endpoint'
] ]
@Field Set parameterKeys = stepConfigurationKeys.plus([
'changeDocumentId',
'transportRequestId',
])
@Field Set generalConfigurationKeys = stepConfigurationKeys @Field Set generalConfigurationKeys = stepConfigurationKeys
def call(parameters = [:]) { def call(parameters = [:]) {
@ -41,34 +38,30 @@ def call(parameters = [:]) {
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys) .mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys) .mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
.mixin(parameters, parameterKeys) .mixin(parameters, parameterKeys)
.withMandatoryProperty('changeDocumentId')
.withMandatoryProperty('transportRequestId')
.withMandatoryProperty('endpoint')
.use() .use()
def changeDocumentId = configuration.changeDocumentId echo "[INFO] Closing transport request '${configuration.transportRequestId}' for change document '${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'."
withCredentials([usernamePassword( withCredentials([usernamePassword(
credentialsId: credentialsId, credentialsId: configuration.credentialsId,
passwordVariable: 'password', passwordVariable: 'password',
usernameVariable: 'username')]) { usernameVariable: 'username')]) {
try { 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) { } catch(ChangeManagementException ex) {
throw new AbortException(ex.getMessage()) throw new AbortException(ex.getMessage())
} }
} }
echo "[INFO] Transport Request '${transportRequestId}' has been successfully closed." echo "[INFO] Transport Request '${configuration.transportRequestId}' has been successfully closed."
} }
} }

View File

@ -11,21 +11,6 @@ import hudson.AbortException
@Field def STEP_NAME = 'transportRequestUploadFile' @Field def STEP_NAME = 'transportRequestUploadFile'
@Field Set parameterKeys = [
'changeDocumentId',
'cmClientOpts',
'transportRequestId',
'applicationId',
'filePath',
'credentialsId',
'endpoint',
'gitFrom',
'gitTo',
'gitChangeDocumentLabel',
'gitTransportRequestLabel',
'gitFormat'
]
@Field Set generalConfigurationKeys = [ @Field Set generalConfigurationKeys = [
'credentialsId', 'credentialsId',
'cmClientOpts', 'cmClientOpts',
@ -37,6 +22,12 @@ import hudson.AbortException
'gitFormat' 'gitFormat'
] ]
@Field Set parameterKeys = generalConfigurationKeys.plus([
'applicationId',
'changeDocumentId',
'filePath',
'transportRequestId'])
@Field Set stepConfigurationKeys = generalConfigurationKeys @Field Set stepConfigurationKeys = generalConfigurationKeys
def call(parameters = [:]) { def call(parameters = [:]) {
@ -47,13 +38,17 @@ def call(parameters = [:]) {
ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script) ChangeManagement cm = parameters.cmUtils ?: new ChangeManagement(script)
Map configuration = ConfigurationHelper ConfigurationHelper configHelper =
.loadStepDefaults(this) ConfigurationHelper.loadStepDefaults(this)
.mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys) .mixinGeneralConfig(script.commonPipelineEnvironment, generalConfigurationKeys)
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys) .mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys) .mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
.mixin(parameters, parameterKeys) .mixin(parameters, parameterKeys)
.use() .withMandatoryProperty('endpoint')
.withMandatoryProperty('applicationId')
.withMandatoryProperty('filePath')
Map configuration = configHelper.use()
def changeDocumentId = configuration.changeDocumentId def changeDocumentId = configuration.changeDocumentId
@ -81,7 +76,6 @@ def call(parameters = [:]) {
} }
} }
def transportRequestId = configuration.transportRequestId def transportRequestId = configuration.transportRequestId
if(transportRequestId?.trim()) { if(transportRequestId?.trim()) {
@ -108,38 +102,36 @@ def call(parameters = [:]) {
} }
} }
if(! changeDocumentId?.trim()) { configuration = configHelper
throw new AbortException("Change document id not provided (parameter: 'changeDocumentId' or via commit history).") .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).") echo "[INFO] Uploading file '${configuration.filePath}' to transport request '${configuration.transportRequestId}' of change document '${configuration.changeDocumentId}'."
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'."
withCredentials([usernamePassword( withCredentials([usernamePassword(
credentialsId: credentialsId, credentialsId: configuration.credentialsId,
passwordVariable: 'password', passwordVariable: 'password',
usernameVariable: 'username')]) { usernameVariable: 'username')]) {
try { 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) { } catch(ChangeManagementException ex) {
throw new AbortException(ex.getMessage()) 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}'."
} }
} }