1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00

docker params as map for fileUpload

This commit is contained in:
Marcus Holl 2019-02-12 13:44:09 +01:00
parent 2aa9f5215a
commit dc1dfd622c
6 changed files with 50 additions and 40 deletions

View File

@ -17,8 +17,11 @@ general:
to: 'HEAD' to: 'HEAD'
format: '%b' format: '%b'
rfc: rfc:
dockerImage: 'rfc' docker:
dockerOptions: [] image: 'rfc'
options: []
envVars: {}
imagePull: true
githubApiUrl: 'https://api.github.com' githubApiUrl: 'https://api.github.com'
githubServerUrl: 'https://github.com' githubServerUrl: 'https://github.com'
gitSshKeyCredentialsId: '' #needed to allow sshagent to run with local ssh key gitSshKeyCredentialsId: '' #needed to allow sshagent to run with local ssh key

View File

@ -64,7 +64,7 @@ public class ChangeManagement implements Serializable {
} }
boolean isChangeInDevelopment(String changeId, String endpoint, String credentialsId, String clientOpts = '') { boolean isChangeInDevelopment(String changeId, String endpoint, String credentialsId, String clientOpts = '') {
int rc = executeWithCredentials(BackendType.SOLMAN, '', [], endpoint, credentialsId, 'is-change-in-development', ['-cID', "'${changeId}'", '--return-code'], int rc = executeWithCredentials(BackendType.SOLMAN, [:], endpoint, credentialsId, 'is-change-in-development', ['-cID', "'${changeId}'", '--return-code'],
false, false,
clientOpts) as int clientOpts) as int
@ -79,7 +79,7 @@ public class ChangeManagement implements Serializable {
String createTransportRequestCTS(String transportType, String targetSystemId, String description, String endpoint, String credentialsId, String clientOpts = '') { String createTransportRequestCTS(String transportType, String targetSystemId, String description, String endpoint, String credentialsId, String clientOpts = '') {
try { try {
def transportRequest = executeWithCredentials(BackendType.CTS, '', [], endpoint, credentialsId, 'create-transport', def transportRequest = executeWithCredentials(BackendType.CTS, [:], endpoint, credentialsId, 'create-transport',
['-tt', transportType, '-ts', targetSystemId, '-d', "\"${description}\""], ['-tt', transportType, '-ts', targetSystemId, '-d', "\"${description}\""],
true, true,
clientOpts) clientOpts)
@ -92,7 +92,7 @@ public class ChangeManagement implements Serializable {
String createTransportRequestSOLMAN(String changeId, String developmentSystemId, String endpoint, String credentialsId, String clientOpts = '') { String createTransportRequestSOLMAN(String changeId, String developmentSystemId, String endpoint, String credentialsId, String clientOpts = '') {
try { try {
def transportRequest = executeWithCredentials(BackendType.SOLMAN, '', [], endpoint, credentialsId, 'create-transport', ['-cID', changeId, '-dID', developmentSystemId], def transportRequest = executeWithCredentials(BackendType.SOLMAN, [:], endpoint, credentialsId, 'create-transport', ['-cID', changeId, '-dID', developmentSystemId],
true, true,
clientOpts) clientOpts)
return (transportRequest as String)?.trim() return (transportRequest as String)?.trim()
@ -121,8 +121,7 @@ public class ChangeManagement implements Serializable {
def transportRequestId = executeWithCredentials( def transportRequestId = executeWithCredentials(
BackendType.RFC, BackendType.RFC,
dockerImage, [image: dockerImage, options: dockerOptions],
dockerOptions,
endpoint, endpoint,
credentialsId, credentialsId,
command, command,
@ -154,8 +153,7 @@ public class ChangeManagement implements Serializable {
int rc = executeWithCredentials( int rc = executeWithCredentials(
BackendType.SOLMAN, BackendType.SOLMAN,
'', [:],
[],
endpoint, endpoint,
credentialsId, credentialsId,
'upload-file-to-transport', 'upload-file-to-transport',
@ -183,8 +181,7 @@ public class ChangeManagement implements Serializable {
int rc = executeWithCredentials( int rc = executeWithCredentials(
BackendType.CTS, BackendType.CTS,
'', [:],
[],
endpoint, endpoint,
credentialsId, credentialsId,
'upload-file-to-transport', 'upload-file-to-transport',
@ -199,8 +196,7 @@ public class ChangeManagement implements Serializable {
} }
void uploadFileToTransportRequestRFC( void uploadFileToTransportRequestRFC(
String dockerImage, Map docker,
List dockerOptions,
String transportRequestId, String transportRequestId,
String applicationName, String applicationName,
String filePath, String filePath,
@ -222,8 +218,7 @@ public class ChangeManagement implements Serializable {
int rc = executeWithCredentials( int rc = executeWithCredentials(
BackendType.RFC, BackendType.RFC,
dockerImage, docker,
dockerOptions,
endpoint, endpoint,
credentialsId, credentialsId,
"cts uploadToABAP:${transportRequestId}", "cts uploadToABAP:${transportRequestId}",
@ -238,8 +233,7 @@ public class ChangeManagement implements Serializable {
def executeWithCredentials( def executeWithCredentials(
BackendType type, BackendType type,
String dockerImage, Map docker,
List dockerOptions,
String endpoint, String endpoint,
String credentialsId, String credentialsId,
String command, String command,
@ -283,8 +277,10 @@ public class ChangeManagement implements Serializable {
script.dockerExecute( script.dockerExecute(
script: script, script: script,
dockerImage: dockerImage, dockerImage: docker.image,
dockerEnvVars: args ) { dockerOptions: docker.options,
dockerEnvVars: (docker.envVars?:[:]).plus(args),
dockerPullImage: docker.pullImage) {
result = script.sh(shArgs) result = script.sh(shArgs)
@ -331,8 +327,7 @@ public class ChangeManagement implements Serializable {
int rc = executeWithCredentials( int rc = executeWithCredentials(
BackendType.SOLMAN, BackendType.SOLMAN,
'', [:],
[],
endpoint, endpoint,
credentialsId, credentialsId,
cmd, cmd,
@ -358,8 +353,7 @@ public class ChangeManagement implements Serializable {
int rc = executeWithCredentials( int rc = executeWithCredentials(
BackendType.CTS, BackendType.CTS,
'', [:],
[],
endpoint, endpoint,
credentialsId, credentialsId,
cmd, cmd,
@ -388,8 +382,8 @@ public class ChangeManagement implements Serializable {
int rc = executeWithCredentials( int rc = executeWithCredentials(
BackendType.RFC, BackendType.RFC,
dockerImage, [image: dockerImage,
dockerOptions, options: dockerOptions],
endpoint, endpoint,
credentialsId, credentialsId,
cmd, cmd,

View File

@ -155,7 +155,10 @@ public class TransportRequestReleaseTest extends BasePiperTest {
credentialsId: 'CM', credentialsId: 'CM',
type: 'RFC', type: 'RFC',
endpoint: 'https://example.org/rfc', endpoint: 'https://example.org/rfc',
rfc: [dockerImage: 'rfc'] rfc: [
dockerImage: 'rfc',
dockerOptions: [],
]
] ]
ChangeManagement cm = new ChangeManagement(nullScript) { ChangeManagement cm = new ChangeManagement(nullScript) {

View File

@ -225,8 +225,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
def cm = new ChangeManagement(nullScript) { def cm = new ChangeManagement(nullScript) {
void uploadFileToTransportRequestRFC( void uploadFileToTransportRequestRFC(
String dockerImage, Map docker,
List dockerOptions,
String transportRequestId, String transportRequestId,
String applicationId, String applicationId,
String applicationURL, String applicationURL,
@ -238,8 +237,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
String abapPackage) { String abapPackage) {
cmUtilsReceivedParams = [ cmUtilsReceivedParams = [
dockerImage: dockerImage, docker: docker,
dockerOptions: dockerOptions,
transportRequestId: transportRequestId, transportRequestId: transportRequestId,
applicationName: applicationId, applicationName: applicationId,
applicationURL: applicationURL, applicationURL: applicationURL,
@ -269,8 +267,12 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
assert cmUtilsReceivedParams == assert cmUtilsReceivedParams ==
[ [
dockerImage: 'rfc', docker: [
dockerOptions: [], image: 'rfc',
options: [],
envVars: [:],
imagePull: true
],
transportRequestId: '123456', transportRequestId: '123456',
applicationName: '42', applicationName: '42',
applicationURL: 'http://example.org/blobstore/xyz.zip', applicationURL: 'http://example.org/blobstore/xyz.zip',
@ -292,8 +294,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
def cm = new ChangeManagement(nullScript) { def cm = new ChangeManagement(nullScript) {
void uploadFileToTransportRequestRFC( void uploadFileToTransportRequestRFC(
String dockerImage, Map docker,
List dockerOptions,
String transportRequestId, String transportRequestId,
String applicationId, String applicationId,
String applicationURL, String applicationURL,
@ -313,6 +314,12 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
changeManagement: [ changeManagement: [
type: 'RFC', type: 'RFC',
rfc: [ rfc: [
docker: [
image: 'rfc',
options: [],
envVars: [:],
imagePull: false,
],
developmentClient: '002', developmentClient: '002',
developmentInstance: '001', developmentInstance: '001',
] ]

View File

@ -277,8 +277,7 @@ public void testGetCommandLineWithCMClientOpts() {
public void testUploadFileToTransportSucceedsRFC() { public void testUploadFileToTransportSucceedsRFC() {
new ChangeManagement(nullScript).uploadFileToTransportRequestRFC( new ChangeManagement(nullScript).uploadFileToTransportRequestRFC(
'rfc', [image:'rfc', options: [], pullImage: true],
[],
'002', //transportRequestId '002', //transportRequestId
'001', // applicationId '001', // applicationId
'https://example.org/mypath/deployArtifact.zip', 'https://example.org/mypath/deployArtifact.zip',
@ -290,7 +289,9 @@ public void testGetCommandLineWithCMClientOpts() {
'XYZ' // abapPackage 'XYZ' // abapPackage
) )
assert dockerExecuteRule.dockerParams.dockerImage == 'rfc' assert dockerExecuteRule.dockerParams.dockerImage == 'rfc'
assert dockerExecuteRule.dockerParams.dockerPullImage == true
assert dockerExecuteRule.dockerParams.dockerEnvVars == assert dockerExecuteRule.dockerParams.dockerEnvVars ==
[ [
@ -317,8 +318,7 @@ public void testGetCommandLineWithCMClientOpts() {
script.setReturnValue('cts uploadToABAP:002', 1) script.setReturnValue('cts uploadToABAP:002', 1)
new ChangeManagement(nullScript).uploadFileToTransportRequestRFC( new ChangeManagement(nullScript).uploadFileToTransportRequestRFC(
'rfc', [:],
[],
'002', //transportRequestId '002', //transportRequestId
'001', // applicationId '001', // applicationId
'https://example.org/mypath/deployArtifact.zip', 'https://example.org/mypath/deployArtifact.zip',

View File

@ -68,6 +68,10 @@ void call(parameters = [:]) {
.withMandatoryProperty('applicationUrl', null, { backendType == BackendType.RFC }) .withMandatoryProperty('applicationUrl', null, { backendType == BackendType.RFC })
.withMandatoryProperty('changeManagement/rfc/developmentInstance', null, { backendType == BackendType.RFC }) .withMandatoryProperty('changeManagement/rfc/developmentInstance', null, { backendType == BackendType.RFC })
.withMandatoryProperty('changeManagement/rfc/developmentClient', null, { backendType == BackendType.RFC }) .withMandatoryProperty('changeManagement/rfc/developmentClient', null, { backendType == BackendType.RFC })
.withMandatoryProperty('changeManagement/rfc/docker/image', null, {backendType == BackendType.RFC})
.withMandatoryProperty('changeManagement/rfc/docker/options', null, {backendType == BackendType.RFC})
.withMandatoryProperty('changeManagement/rfc/docker/envVars', null, {backendType == BackendType.RFC})
.withMandatoryProperty('changeManagement/rfc/docker/imagePull', null, {backendType == BackendType.RFC})
.withMandatoryProperty('applicationDescription', null, { backendType == BackendType.RFC }) .withMandatoryProperty('applicationDescription', null, { backendType == BackendType.RFC })
.withMandatoryProperty('abapPackage', null, { backendType == BackendType.RFC }) .withMandatoryProperty('abapPackage', null, { backendType == BackendType.RFC })
.withMandatoryProperty('applicationId', null, {backendType == BackendType.SOLMAN}) .withMandatoryProperty('applicationId', null, {backendType == BackendType.SOLMAN})
@ -137,8 +141,7 @@ void call(parameters = [:]) {
case BackendType.RFC: case BackendType.RFC:
cm.uploadFileToTransportRequestRFC( cm.uploadFileToTransportRequestRFC(
configuration.changeManagement.rfc.dockerImage, configuration.changeManagement.rfc.docker ?: [],
configuration.changeManagement.rfc.dockerOptions ?: [],
configuration.transportRequestId, configuration.transportRequestId,
configuration.applicationName, configuration.applicationName,
configuration.applicationUrl, configuration.applicationUrl,