mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
make sh returnStdout or returnStatus configurable inside ChangeManagement toolset
This commit is contained in:
parent
c63e6e88c0
commit
a021f0bea9
@ -66,6 +66,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(endpoint, credentialsId, 'is-change-in-development', ['-cID', "'${changeId}'", '--return-code'],
|
int rc = executeWithCredentials(endpoint, credentialsId, 'is-change-in-development', ['-cID', "'${changeId}'", '--return-code'],
|
||||||
|
false,
|
||||||
clientOpts) as int
|
clientOpts) as int
|
||||||
|
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
@ -80,6 +81,7 @@ public class ChangeManagement implements Serializable {
|
|||||||
String createTransportRequest(String changeId, String developmentSystemId, String endpoint, String credentialsId, String clientOpts = '') {
|
String createTransportRequest(String changeId, String developmentSystemId, String endpoint, String credentialsId, String clientOpts = '') {
|
||||||
try {
|
try {
|
||||||
def transportRequest = executeWithCredentials(endpoint, credentialsId, 'create-transport', ['-cID', changeId, '-dID', developmentSystemId],
|
def transportRequest = executeWithCredentials(endpoint, credentialsId, 'create-transport', ['-cID', changeId, '-dID', developmentSystemId],
|
||||||
|
false,
|
||||||
clientOpts)
|
clientOpts)
|
||||||
return transportRequest.trim() as String
|
return transportRequest.trim() as String
|
||||||
}catch(AbortException e) {
|
}catch(AbortException e) {
|
||||||
@ -92,6 +94,7 @@ public class ChangeManagement implements Serializable {
|
|||||||
int rc = executeWithCredentials(endpoint, credentialsId, 'upload-file-to-transport', ['-cID', changeId,
|
int rc = executeWithCredentials(endpoint, credentialsId, 'upload-file-to-transport', ['-cID', changeId,
|
||||||
'-tID', transportRequestId,
|
'-tID', transportRequestId,
|
||||||
applicationId, "\"$filePath\""],
|
applicationId, "\"$filePath\""],
|
||||||
|
false,
|
||||||
cmclientOpts) as int
|
cmclientOpts) as int
|
||||||
|
|
||||||
if(rc == 0) {
|
if(rc == 0) {
|
||||||
@ -102,7 +105,7 @@ public class ChangeManagement implements Serializable {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def executeWithCredentials(String endpoint, String credentialsId, String command, List<String> args, String clientOpts = '') {
|
def executeWithCredentials(String endpoint, String credentialsId, String command, List<String> args, boolean returnStdout = false, String clientOpts = '') {
|
||||||
script.withCredentials([script.usernamePassword(
|
script.withCredentials([script.usernamePassword(
|
||||||
credentialsId: credentialsId,
|
credentialsId: credentialsId,
|
||||||
passwordVariable: 'password',
|
passwordVariable: 'password',
|
||||||
@ -110,19 +113,24 @@ public class ChangeManagement implements Serializable {
|
|||||||
def cmScript = getCMCommandLine(endpoint, script.username, script.password,
|
def cmScript = getCMCommandLine(endpoint, script.username, script.password,
|
||||||
command, args,
|
command, args,
|
||||||
clientOpts)
|
clientOpts)
|
||||||
|
|
||||||
|
Map shArgs = [:]
|
||||||
|
if(returnStdout)
|
||||||
|
shArgs.put('returnStdout', true)
|
||||||
|
else
|
||||||
|
shArgs.put('returnStatus', true)
|
||||||
|
|
||||||
|
shArgs.put('script', cmScript)
|
||||||
|
|
||||||
// user and password are masked by withCredentials
|
// user and password are masked by withCredentials
|
||||||
script.echo """[INFO] Executing command line: "${cmScript}"."""
|
script.echo """[INFO] Executing command line: "${cmScript}"."""
|
||||||
def returnValue = script.sh(returnStatus: true,
|
return script.sh(shArgs)
|
||||||
script: cmScript)
|
|
||||||
return returnValue;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void releaseTransportRequest(String changeId, String transportRequestId, String endpoint, String credentialsId, String clientOpts = '') {
|
void releaseTransportRequest(String changeId, String transportRequestId, String endpoint, String credentialsId, String clientOpts = '') {
|
||||||
int rc = executeWithCredentials( endpoint, credentialsId, 'release-transport', ['-cID', changeId,
|
int rc = executeWithCredentials( endpoint, credentialsId, 'release-transport', ['-cID', changeId,
|
||||||
'-tID', transportRequestId], clientOpts) as int
|
'-tID', transportRequestId], false, clientOpts) as int
|
||||||
if(rc == 0) {
|
if(rc == 0) {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user