1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-03 15:02:35 +02:00

TransportRequestUploadFile migration to Go - CTS (#3098)

* UploadFile CTS
- migrate to GO implementation
This commit is contained in:
Roland Stengel 2021-09-16 13:18:03 +02:00 committed by GitHub
parent 86e8125279
commit cacdb2b867
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 66 deletions

View File

@ -179,7 +179,7 @@ func transportRequestUploadCTSMetadata() config.StepData {
Scope: []string{"PARAMETERS", "STAGES", "STEPS", "GENERAL"},
Type: "string",
Mandatory: false,
Aliases: []config.Alias{},
Aliases: []config.Alias{{Name: "applicationDescription"}},
Default: `Deployed with Piper based on SAP Fiori tools`,
},
{

View File

@ -18,6 +18,8 @@ spec:
- name: description
type: string
description: "The description of the application. The description is only taken into account for a new upload. In case of an update the description will not be updated."
aliases:
- name: applicationDescription
default: "Deployed with Piper based on SAP Fiori tools"
scope:
- PARAMETERS

View File

@ -131,7 +131,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
thrown.expect(AbortException)
thrown.expectMessage("Exception message")
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
throw new AbortException('Exception message')
}
)
@ -156,35 +156,18 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
loggingRule.expect("[INFO] Uploading application 'myApp' to transport request '002'.")
loggingRule.expect("[INFO] Application 'myApp' has been successfully uploaded to transport request '002'.")
ChangeManagement cm = new ChangeManagement(nullScript) {
void uploadFileToTransportRequestCTS(
Map docker,
String transportRequestId,
String endpoint,
String client,
String appName,
String appDescription,
String abapPackage,
String osDeployUser,
def deployToolsDependencies,
def npmInstallArgs,
String deployConfigFile,
String credentialsId) {
def calledWithParameters,
calledWithStepName,
calledWithMetadata,
calledWithCredentials
cmUtilReceivedParams.docker = docker
cmUtilReceivedParams.transportRequestId = transportRequestId
cmUtilReceivedParams.endpoint = endpoint
cmUtilReceivedParams.client = client
cmUtilReceivedParams.appName = appName
cmUtilReceivedParams.appDescription = appDescription
cmUtilReceivedParams.abapPackage = abapPackage
cmUtilReceivedParams.osDeployUser = osDeployUser
cmUtilReceivedParams.deployToolDependencies = deployToolsDependencies
cmUtilReceivedParams.npmInstallOpts = npmInstallArgs
cmUtilReceivedParams.deployConfigFile = deployConfigFile
cmUtilReceivedParams.credentialsId = credentialsId
}
}
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
params, stepName, metaData, creds ->
calledWithParameters = params
calledWithStepName = stepName
calledWithMetadata = metaData
calledWithCredentials = creds
})
stepRule.step.transportRequestUploadFile(script: nullScript,
changeManagement: [
@ -200,28 +183,20 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
applicationDescription: 'the description',
abapPackage: 'myPackage',
transportRequestId: '002',
cmUtils: cm)
credentialsId: 'CM')
assert cmUtilReceivedParams ==
[
docker: [
image: 'node',
options:[],
envVars:[:],
pullImage:true
],
transportRequestId: '002',
endpoint: 'https://example.org/cm',
client: '001',
appName: 'myApp',
appDescription: 'the description',
abapPackage: 'myPackage',
osDeployUser: 'node2',
deployToolDependencies: ['@ui5/cli', '@sap/ux-ui5-tooling', '@ui5/logger', '@ui5/fs', '@dummy/foo'],
npmInstallOpts: ['--verbose'],
deployConfigFile: 'ui5-deploy.yaml',
credentialsId: 'CM',
]
assertThat(calledWithStepName, is('transportRequestUploadCTS'))
assertThat(calledWithParameters.transportRequestId, is('002'))
assertThat(calledWithParameters.endpoint, is('https://example.org/cm'))
assertThat(calledWithParameters.client, is('001'))
assertThat(calledWithParameters.applicationName, is('myApp'))
assertThat(calledWithParameters.description, is('the description'))
assertThat(calledWithParameters.abapPackage, is('myPackage'))
assertThat(calledWithParameters.osDeployUser, is('node2'))
assertThat(calledWithParameters.deployToolDependencies, is(['@ui5/cli', '@sap/ux-ui5-tooling', '@ui5/logger', '@ui5/fs', '@dummy/foo']))
assertThat(calledWithParameters.npmInstallOpts, is(['--verbose']))
assertThat(calledWithParameters.deployConfigFile, is('ui5-deploy.yaml'))
assertThat(calledWithParameters.uploadCredentialsId, is('CM'))
}
@Test
@ -343,7 +318,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
loggingRule.expect("[INFO] Uploading file '/path' to transport request '002' of change document '001'.")
loggingRule.expect("[INFO] File '/path' has been successfully uploaded to transport request '002' of change document '001'.")
def calledWithParameters,
calledWithStepName,
calledWithMetadata,
@ -397,7 +372,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
calledWithCredentials = creds
}
)
nullScript.commonPipelineEnvironment.configuration.put(['steps',
[transportRequestUploadFile:
[applicationId: 'AppIdfromConfig']]])

View File

@ -256,19 +256,18 @@ void call(Map parameters = [:]) {
echo "[INFO] Uploading application '${configuration.applicationName}' to transport request '${configuration.transportRequestId}'."
cm.uploadFileToTransportRequestCTS(
configuration.changeManagement.cts?.nodeDocker ?: [:],
configuration.transportRequestId,
configuration.changeManagement.endpoint,
configuration.changeManagement.client,
configuration.applicationName,
configuration.applicationDescription,
configuration.abapPackage,
configuration.changeManagement.cts.osDeployUser,
configuration.changeManagement.cts.deployToolDependencies,
configuration.changeManagement.cts.npmInstallOpts,
configuration.changeManagement.cts.deployConfigFile,
configuration.changeManagement.credentialsId)
transportRequestUploadCTS(script: script,
transportRequestId: configuration.transportRequestId,
endpoint: configuration.changeManagement.endpoint,
client: configuration.changeManagement.client,
applicationName: configuration.applicationName,
description: configuration.applicationDescription,
abapPackage: configuration.abapPackage,
osDeployUser: configuration.changeManagement.cts.osDeployUser,
deployToolDependencies: configuration.changeManagement.cts.deployToolDependencies,
npmInstallOpts: configuration.changeManagement.cts.npmInstallOpts,
deployConfigFile: configuration.changeManagement.cts.deployConfigFile,
uploadCredentialsId: configuration.changeManagement.credentialsId)
echo "[INFO] Application '${configuration.applicationName}' has been successfully uploaded to transport request '${configuration.transportRequestId}'."