mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-03-05 15:15:44 +02:00
commit
f71b0b797e
@ -1,7 +1,10 @@
|
||||
# transportRequestCreate
|
||||
|
||||
## Description
|
||||
Creates a Transport Request for a Change Document on the Solution Manager.
|
||||
Creates
|
||||
|
||||
* a Transport Request for a Change Document on the Solution Manager (type `SOLMAN`) or
|
||||
* a Transport Request inside an ABAP system (type`CTS`)
|
||||
|
||||
## Prerequisites
|
||||
* **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central.
|
||||
@ -10,7 +13,10 @@ Creates a Transport Request for a Change Document on the Solution Manager.
|
||||
| parameter | mandatory | default | possible values |
|
||||
| -----------------|-----------|--------------------------------------------------------|--------------------|
|
||||
| `script` | yes | | |
|
||||
| `changeDocumentId` | yes | | |
|
||||
| `changeDocumentId` | for `SOLMAN` | | |
|
||||
| `transportType` | for `CTS` | no | |
|
||||
| `targetSystem` | for `CTS` | no | |
|
||||
| `description` | for `CTS` | no | |
|
||||
| `changeManagement/credentialsId` | yes | | |
|
||||
| `changeManagement/endpoint` | yes | | |
|
||||
| `changeManagement/clientOpts` | no | | |
|
||||
@ -18,16 +24,21 @@ Creates a Transport Request for a Change Document on the Solution Manager.
|
||||
| `changeManagement/git/to` | no | `HEAD` | |
|
||||
| `changeManagement/changeDocumentLabel` | no | `ChangeDocument\s?:` | regex pattern |
|
||||
| `changeManagement/git/format` | no | `%b` | see `git log --help` |
|
||||
| `changeManagement/type` | no | `SOLMAN` | `SOLMAN`, `CTS` |
|
||||
|
||||
* `script` - The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the `this` parameter, as in `script: this`. This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md) for retrieving, for example, configuration parameters.
|
||||
* `changeDocumentId` - The id of the change document to transport.
|
||||
* `changeManagement/credentialsId` - The credentials to connect to the Solution Manager.
|
||||
* `changeManagement/endpoint` - The address of the Solution Manager.
|
||||
* `changeDocumentId` - for `SOLMAN` only. The id of the change document to that the transport request is bound to. Typically this value is provided via commit message in the commit history.
|
||||
* `changeManagement/type` Where/how the transport request is created (via SAP Solution Manager, ABAP).
|
||||
* `changeManagement/credentialsId` - The credentials to connect to the service endpoint (Solution Manager, ABAP System).
|
||||
* `changeManagement/endpoint` - The service endpoint (Solution Manager, ABAP System).
|
||||
* `changeManagement/clientOpts`- Options forwarded to JVM used by the CM client, like `JAVA_OPTS`
|
||||
* `changeManagement/git/from` - The starting point for retrieving the change document id
|
||||
* `changeManagement/git/to` - The end point for retrieving the change document id
|
||||
* `changeManagement/changeDocumentLabel` - A pattern used for identifying lines holding the change document id.
|
||||
* `changeManagement/changeDocumentLabel` - For type `SOLMAN` only. A pattern used for identifying lines holding the change document id.
|
||||
* `changeManagement/git/format` - Specifies what part of the commit is scanned. By default the body of the commit message is scanned.
|
||||
* `description` - for `CTS` only. The description of the transport request.
|
||||
* `targetSystem` - for `CTS` only. The system receiving the transport request.
|
||||
* `transportType` - for type `CTS` only. Typically `W` (workbench) or `C` customizing.
|
||||
|
||||
## Step configuration
|
||||
The step is configured using a customer configuration file provided as
|
||||
@ -55,6 +66,7 @@ general:
|
||||
changeDocumentLabel: 'ChangeDocument\s?:'
|
||||
cmClientOpts: '-Djavax.net.ssl.trustStore=<path to truststore>'
|
||||
credentialsId: 'CM'
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
git:
|
||||
from: 'HEAD~1'
|
||||
@ -72,6 +84,7 @@ The properties can also be configured on a per-step basis:
|
||||
steps:
|
||||
transportRequestCreate:
|
||||
changeManagement:
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
[...]
|
||||
```
|
||||
@ -89,9 +102,20 @@ The id of the Transport Request that has been created.
|
||||
|
||||
## Example
|
||||
```groovy
|
||||
// SOLMAN
|
||||
def transportRequestId = transportRequestCreate script:this,
|
||||
changeDocumentId: '001,'
|
||||
changeManagement: [
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
// CTS
|
||||
def transportRequestId = transportRequestCreate script:this,
|
||||
transportType: 'W',
|
||||
targetSystem: 'XYZ',
|
||||
description: 'the description',
|
||||
changeManagement: [
|
||||
type: 'CTS'
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
```
|
||||
|
@ -1,7 +1,7 @@
|
||||
# transportRequestRelease
|
||||
|
||||
## Description
|
||||
Releases a Transport Request for a Change Document on the Solution Manager.
|
||||
Releases a Transport Request.
|
||||
|
||||
## Prerequisites
|
||||
* **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central.
|
||||
@ -10,7 +10,7 @@ Releases a Transport Request for a Change Document on the Solution Manager.
|
||||
| parameter | mandatory | default | possible values |
|
||||
| -----------------|-----------|--------------------------------------------------------|--------------------|
|
||||
| `script` | yes | | |
|
||||
| `changeDocumentId` | yes | | |
|
||||
| `changeDocumentId` | `SOLMAN` only | | |
|
||||
| `transportRequestId`| yes | | |
|
||||
| `changeManagement/changeDocumentLabel` | no | `ChangeDocument\s?:` | regex pattern |
|
||||
| `changeManagment/transportRequestLabel` | no | `TransportRequest\s?:` | regex pattern |
|
||||
@ -19,16 +19,17 @@ Releases a Transport Request for a Change Document on the Solution Manager.
|
||||
| `changeManagement/git/from` | no | `origin/master` | |
|
||||
| `changeManagement/git/to` | no | `HEAD` | |
|
||||
| `changeManagement/git/format` | no | `%b` | see `git log --help` |
|
||||
| `changeManagement/type` | no | `SOLMAN` | `SOLMAN`, `CTS` |
|
||||
|
||||
* `script` - The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the `this` parameter, as in `script: this`. This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md) for retrieving, for example, configuration parameters.
|
||||
* `changeDocumentId` - The id of the change document related to the transport request to release.
|
||||
* `changeDocumentId` - for `SOLMAN` only. The id of the change document related to the transport request to release.
|
||||
* `transportRequestId` - The id of the transport request to release.
|
||||
* `changeManagement/changeDocumentLabel` - A pattern used for identifying lines holding the change document id.
|
||||
* `changeManagement/changeDocumentLabel` - for `SOLMAN` only. A pattern used for identifying lines holding the change document id.
|
||||
* `changeManagment/transportRequestLabel` - A pattern used for identifying lines holding the transport request id.
|
||||
* `changeManagement/credentialsId` - The id of the credentials to connect to the Solution Manager. The credentials needs to be maintained on Jenkins.
|
||||
* `changeManagement/endpoint` - The address of the Solution Manager.
|
||||
* `changeManagement/git/from` - The starting point for retrieving the change document id
|
||||
* `changeManagement/git/to` - The end point for retrieving the change document id
|
||||
* `changeManagement/credentialsId` - The credentials to connect to the service endpoint (Solution Manager, ABAP System).
|
||||
* `changeManagement/endpoint` - The service endpoint (Solution Manager, ABAP System).
|
||||
* `changeManagement/git/from` - The starting point for retrieving the change document id and/or transport request id
|
||||
* `changeManagement/git/to` - The end point for retrieving the change document id and/or transport request id
|
||||
* `changeManagement/git/format` - Specifies what part of the commit is scanned. By default the body of the commit message is scanned.
|
||||
|
||||
## Step configuration
|
||||
@ -57,6 +58,7 @@ general:
|
||||
changeDocumentLabel: 'ChangeDocument\s?:'
|
||||
cmClientOpts: '-Djavax.net.ssl.trustStore=<path to truststore>'
|
||||
credentialsId: 'CM'
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
git:
|
||||
from: 'HEAD~1'
|
||||
@ -73,6 +75,7 @@ The properties can also be configured on a per-step basis:
|
||||
steps:
|
||||
transportRequestRelease:
|
||||
changeManagement:
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
[...]
|
||||
```
|
||||
@ -84,17 +87,26 @@ None.
|
||||
|
||||
## Exceptions
|
||||
* `IllegalArgumentException`:
|
||||
* If the change id is not provided.
|
||||
* If the change id is not provided (`SOLMAN` only)
|
||||
* If the transport request id is not provided.
|
||||
* `AbortException`:
|
||||
* If the release of the transport request fails.
|
||||
|
||||
## Example
|
||||
```groovy
|
||||
// SOLMAN
|
||||
transportRequestRelease script:this,
|
||||
changeDocumentId: '001',
|
||||
transportRequestId: '001',
|
||||
changeManagement: [
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
// CTS
|
||||
transportRequestRelease script:this,
|
||||
transportRequestId: '001',
|
||||
changeManagement: [
|
||||
type: 'CTS'
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
```
|
||||
|
@ -1,7 +1,7 @@
|
||||
# transportRequestUploadFile
|
||||
|
||||
## Description
|
||||
Uploads a file to a Transport Request for a Change Document on the Solution Manager.
|
||||
Uploads a file to a Transport Request.
|
||||
|
||||
## Prerequisites
|
||||
* **[Change Management Client 2.0.0 or compatible version](http://central.maven.org/maven2/com/sap/devops/cmclient/dist.cli/)** - available for download on Maven Central.
|
||||
@ -10,9 +10,9 @@ Uploads a file to a Transport Request for a Change Document on the Solution Mana
|
||||
| parameter | mandatory | default | possible values |
|
||||
| -----------------|-----------|--------------------------------------------------------|--------------------|
|
||||
| `script` | yes | | |
|
||||
| `changeDocumentId` | yes | | |
|
||||
| `changeDocumentId` | `SOLMAN` only | | |
|
||||
| `transportRequestId`| yes | | |
|
||||
| `applicationId` | yes | | |
|
||||
| `applicationId` | `SOLMAN` only | | |
|
||||
| `filePath` | yes | | |
|
||||
| `changeManagement/credentialsId` | yes | | |
|
||||
| `changeManagement/endpoint` | yes | | |
|
||||
@ -21,18 +21,20 @@ Uploads a file to a Transport Request for a Change Document on the Solution Mana
|
||||
| `changeManagement/changeDocumentLabel` | no | `ChangeDocument\s?:` | regex pattern |
|
||||
| `changeManagement/transportRequestLabel` | no | `TransportRequest\s?:` | regex pattern |
|
||||
| `changeManagement/git/format` | no | `%b` | see `git log --help` |
|
||||
| `changeManagement/type` | no | `SOLMAN` | `SOLMAN`, `CTS` |
|
||||
|
||||
* `script` - The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the `this` parameter, as in `script: this`. This allows the function to access the [`commonPipelineEnvironment`](commonPipelineEnvironment.md) for retrieving, for example, configuration parameters.
|
||||
* `changeDocumentId` - The id of the change document related to the transport request to release.
|
||||
* `transportRequestId` - The id of the transport request to release.
|
||||
* `applicationId` - The id of the application.
|
||||
* `changeDocumentId` - For type `SOLMAN` only. The id of the change document related to the transport request to release. Typically provided via commit history.
|
||||
* `transportRequestId` - The id of the transport request to release. Typically provided via commit history.
|
||||
* `applicationId` - For type `SOLMAN` only. The id of the application.
|
||||
* `filePath` - The path of the file to upload.
|
||||
* `changeManagement/credentialsId` - The credentials to connect to the Solution Manager.
|
||||
* `changeManagement/endpoint` - The address of the Solution Manager.
|
||||
* `changeManagement/git/from` - The starting point for retrieving the change document id
|
||||
* `changeManagement/git/to` - The end point for retrieving the change document id
|
||||
* `changeManagement/changeDocumentLabel` - A pattern used for identifying lines holding the change document id.
|
||||
* `changeManagement/credentialsId` - The credentials to connect to the service endpoint (Solution Manager, ABAP System).
|
||||
* `changeManagement/endpoint` - The service endpoint (Solution Manager, ABAP System).
|
||||
* `changeManagement/git/from` - The starting point for retrieving the change document id and/or transport request id
|
||||
* `changeManagement/git/to` - The end point for retrieving the change document id and/or transport request id
|
||||
* `changeManagement/changeDocumentLabel` - For type `SOLMAN` only. A pattern used for identifying lines holding the change document id.
|
||||
* `changeManagement/transportRequestLabel` - A pattern used for identifying lines holding the transport request id.
|
||||
* `changeManagement/type` Where/how the transport request is created (via SAP Solution Manager, ABAP).
|
||||
* `changeManagement/git/format` - Specifies what part of the commit is scanned. By default the body of the commit message is scanned.
|
||||
|
||||
## Step configuration
|
||||
@ -61,6 +63,7 @@ general:
|
||||
changeDocumentLabel: 'ChangeDocument\s?:'
|
||||
cmClientOpts: '-Djavax.net.ssl.trustStore=<path to truststore>'
|
||||
credentialsId: 'CM'
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
git:
|
||||
from: 'HEAD~1'
|
||||
@ -78,6 +81,7 @@ The properties can also be configured on a per-step basis:
|
||||
transportRequestUploadFile:
|
||||
applicationId: 'FOO'
|
||||
changeManagement:
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
[...]
|
||||
```
|
||||
@ -89,21 +93,31 @@ None.
|
||||
|
||||
## Exceptions
|
||||
* `IllegalArgumentException`:
|
||||
* If the change id is not provided.
|
||||
* If the change id is not provided (`SOLMAN` only).
|
||||
* If the transport request id is not provided.
|
||||
* If the application id is not provided.
|
||||
* If the application id is not provided (`SOLMAN` only).
|
||||
* If the file path is not provided.
|
||||
* `AbortException`:
|
||||
* If the upload fails.
|
||||
|
||||
## Example
|
||||
```groovy
|
||||
// SOLMAN
|
||||
transportRequestUploadFile script:this,
|
||||
changeDocumentId: '001',
|
||||
transportRequestId: '001',
|
||||
changeDocumentId: '001', // typically provided via git commit history
|
||||
transportRequestId: '001', // typically provided via git commit history
|
||||
applicationId: '001',
|
||||
filePath: '/path',
|
||||
changeManagement:[
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
// CTS
|
||||
transportRequestUploadFile script:this,
|
||||
transportRequestId: '001', // typically provided via git commit history
|
||||
filePath: '/path',
|
||||
changeManagement:[
|
||||
type: 'CTS'
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
```
|
||||
|
@ -3,6 +3,7 @@ general:
|
||||
productiveBranch: 'master'
|
||||
collectTelemetryData: true
|
||||
changeManagement:
|
||||
type: 'NONE' # SOLMAN, CTS, NONE
|
||||
transportRequestLabel: 'TransportRequest\s?:'
|
||||
changeDocumentLabel: 'ChangeDocument\s?:'
|
||||
clientOpts: ''
|
||||
|
5
src/com/sap/piper/cm/BackendType.groovy
Normal file
5
src/com/sap/piper/cm/BackendType.groovy
Normal file
@ -0,0 +1,5 @@
|
||||
package com.sap.piper.cm;
|
||||
|
||||
public enum BackendType {
|
||||
SOLMAN, CTS, NONE
|
||||
}
|
@ -63,7 +63,8 @@ public class ChangeManagement implements Serializable {
|
||||
}
|
||||
|
||||
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(BackendType.SOLMAN, endpoint, credentialsId, 'is-change-in-development', ['-cID', "'${changeId}'", '--return-code'],
|
||||
false,
|
||||
clientOpts) as int
|
||||
|
||||
if (rc == 0) {
|
||||
@ -75,22 +76,52 @@ public class ChangeManagement implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
String createTransportRequest(String changeId, String developmentSystemId, String endpoint, String credentialsId, String clientOpts = '') {
|
||||
String createTransportRequestCTS(String transportType, String targetSystemId, String description, String endpoint, String credentialsId, String clientOpts = '') {
|
||||
try {
|
||||
def transportRequest = executeWithCredentials(endpoint, credentialsId, 'create-transport', ['-cID', changeId, '-dID', developmentSystemId],
|
||||
def transportRequest = executeWithCredentials(BackendType.CTS, endpoint, credentialsId, 'create-transport',
|
||||
['-tt', transportType, '-ts', targetSystemId, '-d', "\"${description}\""],
|
||||
true,
|
||||
clientOpts)
|
||||
return (transportRequest as String)?.trim()
|
||||
}catch(AbortException e) {
|
||||
throw new ChangeManagementException("Cannot create a transport request. $e.message.")
|
||||
}
|
||||
}
|
||||
|
||||
String createTransportRequestSOLMAN(String changeId, String developmentSystemId, String endpoint, String credentialsId, String clientOpts = '') {
|
||||
|
||||
try {
|
||||
def transportRequest = executeWithCredentials(BackendType.SOLMAN, endpoint, credentialsId, 'create-transport', ['-cID', changeId, '-dID', developmentSystemId],
|
||||
true,
|
||||
clientOpts)
|
||||
return transportRequest.trim() as String
|
||||
return (transportRequest as String)?.trim()
|
||||
}catch(AbortException e) {
|
||||
throw new ChangeManagementException("Cannot create a transport request for change id '$changeId'. $e.message.")
|
||||
}
|
||||
}
|
||||
|
||||
void uploadFileToTransportRequest(BackendType type, String changeId, String transportRequestId, String applicationId, String filePath, String endpoint, String credentialsId, String cmclientOpts = '') {
|
||||
|
||||
void uploadFileToTransportRequest(String changeId, String transportRequestId, String applicationId, String filePath, String endpoint, String credentialsId, String cmclientOpts = '') {
|
||||
int rc = executeWithCredentials(endpoint, credentialsId, 'upload-file-to-transport', ['-cID', changeId,
|
||||
'-tID', transportRequestId,
|
||||
applicationId, "\"$filePath\""],
|
||||
cmclientOpts) as int
|
||||
def args = null
|
||||
|
||||
if(type == BackendType.SOLMAN) {
|
||||
args = ['-cID', changeId,
|
||||
'-tID', transportRequestId,
|
||||
applicationId, "\"$filePath\""]
|
||||
} else if (type == BackendType.CTS) {
|
||||
args = ['-tID', transportRequestId,
|
||||
"\"$filePath\""]
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid backend type: ${type}")
|
||||
}
|
||||
|
||||
int rc = executeWithCredentials(type,
|
||||
endpoint,
|
||||
credentialsId,
|
||||
'upload-file-to-transport',
|
||||
args,
|
||||
false,
|
||||
cmclientOpts) as int
|
||||
|
||||
if(rc == 0) {
|
||||
return
|
||||
@ -100,27 +131,48 @@ public class ChangeManagement implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
def executeWithCredentials(String endpoint, String credentialsId, String command, List<String> args, String clientOpts = '') {
|
||||
def executeWithCredentials(BackendType type, String endpoint, String credentialsId, String command, List<String> args, boolean returnStdout = false, String clientOpts = '') {
|
||||
script.withCredentials([script.usernamePassword(
|
||||
credentialsId: credentialsId,
|
||||
passwordVariable: 'password',
|
||||
usernameVariable: 'username')]) {
|
||||
def cmScript = getCMCommandLine(endpoint, script.username, script.password,
|
||||
def cmScript = getCMCommandLine(type, endpoint, script.username, script.password,
|
||||
command, args,
|
||||
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
|
||||
script.echo """[INFO] Executing command line: "${cmScript}"."""
|
||||
def returnValue = script.sh(returnStatus: true,
|
||||
script: cmScript)
|
||||
return returnValue;
|
||||
|
||||
return script.sh(shArgs)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void releaseTransportRequest(String changeId, String transportRequestId, String endpoint, String credentialsId, String clientOpts = '') {
|
||||
int rc = executeWithCredentials( endpoint, credentialsId, 'release-transport', ['-cID', changeId,
|
||||
'-tID', transportRequestId], clientOpts) as int
|
||||
void releaseTransportRequest(BackendType type,String changeId, String transportRequestId, String endpoint, String credentialsId, String clientOpts = '') {
|
||||
|
||||
def cmd
|
||||
List args = []
|
||||
|
||||
if(type == BackendType.SOLMAN) {
|
||||
cmd = 'release-transport'
|
||||
args << '-cID'
|
||||
args << changeId
|
||||
} else if(type == BackendType.CTS) {
|
||||
cmd = 'export-transport'
|
||||
} else {
|
||||
throw new IllegalStateException("Invalid backend type: '${type}'")
|
||||
}
|
||||
|
||||
args << '-tID'
|
||||
args << transportRequestId
|
||||
|
||||
int rc = executeWithCredentials(type, endpoint, credentialsId, cmd, args, false, clientOpts) as int
|
||||
if(rc == 0) {
|
||||
return
|
||||
} else {
|
||||
@ -128,7 +180,8 @@ public class ChangeManagement implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
String getCMCommandLine(String endpoint,
|
||||
String getCMCommandLine(BackendType type,
|
||||
String endpoint,
|
||||
String username,
|
||||
String password,
|
||||
String command,
|
||||
@ -143,7 +196,7 @@ public class ChangeManagement implements Serializable {
|
||||
cmclient -e '$endpoint' \
|
||||
-u '$username' \
|
||||
-p '$password' \
|
||||
-t SOLMAN \
|
||||
-t ${type} \
|
||||
${command} ${(args as Iterable).join(' ')}
|
||||
"""
|
||||
return cmCommandLine
|
||||
|
29
src/com/sap/piper/cm/StepHelpers.groovy
Normal file
29
src/com/sap/piper/cm/StepHelpers.groovy
Normal file
@ -0,0 +1,29 @@
|
||||
package com.sap.piper.cm;
|
||||
|
||||
import com.cloudbees.groovy.cps.NonCPS
|
||||
|
||||
public class StepHelpers {
|
||||
|
||||
@NonCPS
|
||||
static BackendType getBackendTypeAndLogInfoIfCMIntegrationDisabled(def step, Map configuration) {
|
||||
|
||||
BackendType backendType
|
||||
|
||||
try {
|
||||
backendType = configuration.changeManagement.type as BackendType
|
||||
} catch(IllegalArgumentException e) {
|
||||
step.error "Invalid backend type: '${configuration.changeManagement.type}'. " +
|
||||
"Valid values: [${BackendType.values().join(', ')}]. " +
|
||||
"Configuration: 'changeManagement/type'."
|
||||
}
|
||||
|
||||
if (backendType == BackendType.NONE) {
|
||||
step.echo "[INFO] Change management integration intentionally switched off. " +
|
||||
"In order to enable it provide 'changeManagement/type with one of " +
|
||||
"[${BackendType.values().minus(BackendType.NONE).join(', ')}] and maintain " +
|
||||
"other required properties like 'endpoint', 'credentialsId'."
|
||||
}
|
||||
|
||||
return backendType
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import com.sap.piper.cm.ChangeManagementException
|
||||
import hudson.AbortException
|
||||
import util.BasePiperTest
|
||||
import util.JenkinsCredentialsRule
|
||||
import util.JenkinsLoggingRule
|
||||
import util.JenkinsReadYamlRule
|
||||
import util.JenkinsStepRule
|
||||
import util.Rules
|
||||
@ -19,6 +20,7 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
|
||||
private ExpectedException thrown = ExpectedException.none()
|
||||
private JenkinsStepRule jsr = new JenkinsStepRule(this)
|
||||
private JenkinsLoggingRule jlr = new JenkinsLoggingRule(this)
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
@ -26,6 +28,7 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
.around(new JenkinsReadYamlRule(this))
|
||||
.around(thrown)
|
||||
.around(jsr)
|
||||
.around(jlr)
|
||||
.around(new JenkinsCredentialsRule(this)
|
||||
.withCredentials('CM', 'anonymous', '********'))
|
||||
|
||||
@ -43,7 +46,9 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
script: nullScript,
|
||||
cmUtils: cm,
|
||||
changeManagement: [endpoint: 'https://example.org/cm'],
|
||||
changeManagement: [
|
||||
type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm'],
|
||||
failIfStatusIsNotInDevelopment: true)
|
||||
|
||||
assert cmUtilReceivedParams == [
|
||||
@ -66,7 +71,8 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
script: nullScript,
|
||||
cmUtils: cm,
|
||||
changeManagement: [endpoint: 'https://example.org/cm'])
|
||||
changeManagement: [type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm'])
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -89,7 +95,8 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
script: nullScript,
|
||||
changeDocumentId: '42',
|
||||
cmUtils: cm,
|
||||
changeManagement: [endpoint: 'https://example.org/cm'])
|
||||
changeManagement: [type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm'])
|
||||
|
||||
assert cmUtilReceivedParams.changeId == '42'
|
||||
}
|
||||
@ -101,7 +108,8 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
script: nullScript,
|
||||
cmUtils: cm,
|
||||
changeManagement : [endpoint: 'https://example.org/cm'])
|
||||
changeManagement : [type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm'])
|
||||
|
||||
assert cmUtilReceivedParams.changeId == '0815'
|
||||
}
|
||||
@ -127,7 +135,8 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
script: nullScript,
|
||||
cmUtils: cm,
|
||||
changeManagement: [endpoint: 'https://example.org/cm'])
|
||||
changeManagement: [type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm'])
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -142,7 +151,8 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
script: nullScript,
|
||||
cmUtils: cm,
|
||||
changeManagement: [endpoint: 'https://example.org/cm'])
|
||||
changeManagement: [endpoint: 'https://example.org/cm',
|
||||
type: 'SOLMAN'])
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -157,7 +167,19 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
script: nullScript,
|
||||
cmUtils: cm,
|
||||
changeManagement: [endpoint: 'https://example.org/cm'])
|
||||
changeManagement: [type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm'])
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cmIntegrationSwichtedOffTest() {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.checkChangeInDevelopment(
|
||||
script: nullScript,
|
||||
changeManagement: [type: 'NONE'])
|
||||
|
||||
}
|
||||
|
||||
private ChangeManagement getChangeManagementUtils(boolean inDevelopment, String changeDocumentId = '001') {
|
||||
|
@ -4,6 +4,7 @@ import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import com.sap.piper.cm.BackendType
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
@ -40,6 +41,7 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
|
||||
[
|
||||
credentialsId: 'CM',
|
||||
type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm',
|
||||
clientOpts: '-DmyProp=myVal',
|
||||
changeDocumentLabel: 'ChangeId\\s?:',
|
||||
@ -84,7 +86,8 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
|
||||
String createTransportRequest(String changeId,
|
||||
String createTransportRequestSOLMAN(
|
||||
String changeId,
|
||||
String developmentSystemId,
|
||||
String cmEndpoint,
|
||||
String credentialId,
|
||||
@ -102,13 +105,14 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createTransportRequestSuccessTest() {
|
||||
public void createTransportRequestSuccessSOLMANTest() {
|
||||
|
||||
def result = [:]
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
|
||||
String createTransportRequest(String changeId,
|
||||
String createTransportRequestSOLMAN(
|
||||
String changeId,
|
||||
String developmentSystemId,
|
||||
String cmEndpoint,
|
||||
String credentialId,
|
||||
@ -136,4 +140,58 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
||||
assert jlr.log.contains("[INFO] Creating transport request for change document '001' and development system '001'.")
|
||||
assert jlr.log.contains("[INFO] Transport Request '001' has been successfully created.")
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createTransportRequestSuccessCTSTest() {
|
||||
|
||||
def result = [:]
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
|
||||
String createTransportRequestCTS(
|
||||
String transportType,
|
||||
String targetSystemId,
|
||||
String description,
|
||||
String endpoint,
|
||||
String credentialsId,
|
||||
String clientOpts
|
||||
) {
|
||||
result.transportType = transportType
|
||||
result.targetSystemId = targetSystemId
|
||||
result.description = description
|
||||
result.endpoint = endpoint
|
||||
result.credentialsId = credentialsId
|
||||
result.clientOpts = clientOpts
|
||||
return '001'
|
||||
}
|
||||
}
|
||||
|
||||
def transportId = jsr.step.call(script: nullScript,
|
||||
transportType: 'W',
|
||||
targetSystem: 'XYZ',
|
||||
description: 'desc',
|
||||
changeManagement: [type: 'CTS'],
|
||||
cmUtils: cm)
|
||||
|
||||
assert transportId == '001'
|
||||
assert result == [transportType: 'W',
|
||||
targetSystemId: 'XYZ',
|
||||
description: 'desc',
|
||||
endpoint: 'https://example.org/cm',
|
||||
credentialsId: 'CM',
|
||||
clientOpts: '-DmyProp=myVal'
|
||||
]
|
||||
|
||||
assert jlr.log.contains("[INFO] Creating transport request.")
|
||||
assert jlr.log.contains("[INFO] Transport Request '001' has been successfully created.")
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cmIntegrationSwichtedOffTest() {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.call(
|
||||
changeManagement: [type: 'NONE'])
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import com.sap.piper.cm.BackendType
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
@ -39,6 +40,7 @@ public class TransportRequestReleaseTest extends BasePiperTest {
|
||||
[changeManagement:
|
||||
[
|
||||
credentialsId: 'CM',
|
||||
type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
]
|
||||
@ -89,7 +91,8 @@ public class TransportRequestReleaseTest extends BasePiperTest {
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
|
||||
void releaseTransportRequest(String changeId,
|
||||
void releaseTransportRequest(BackendType type,
|
||||
String changeId,
|
||||
String transportRequestId,
|
||||
String endpoint,
|
||||
String credentialsId,
|
||||
@ -111,12 +114,14 @@ public class TransportRequestReleaseTest extends BasePiperTest {
|
||||
Map receivedParams = [:]
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
void releaseTransportRequest(String changeId,
|
||||
void releaseTransportRequest(BackendType type,
|
||||
String changeId,
|
||||
String transportRequestId,
|
||||
String endpoint,
|
||||
String credentialsId,
|
||||
String clientOpts) {
|
||||
|
||||
receivedParams.type = type
|
||||
receivedParams.changeId = changeId
|
||||
receivedParams.transportRequestId = transportRequestId
|
||||
receivedParams.endpoint = endpoint
|
||||
@ -127,10 +132,20 @@ public class TransportRequestReleaseTest extends BasePiperTest {
|
||||
|
||||
jsr.step.call(script: nullScript, changeDocumentId: '001', transportRequestId: '002', cmUtils: cm)
|
||||
|
||||
assert receivedParams == [changeId: '001',
|
||||
assert receivedParams == [type: BackendType.SOLMAN,
|
||||
changeId: '001',
|
||||
transportRequestId: '002',
|
||||
endpoint: 'https://example.org/cm',
|
||||
credentialsId: 'CM',
|
||||
clientOpts: '']
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cmIntegrationSwichtedOffTest() {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.call(
|
||||
changeManagement: [type: 'NONE'])
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.rules.RuleChain
|
||||
|
||||
import com.sap.piper.cm.BackendType
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
@ -44,6 +45,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
[changeManagement:
|
||||
[
|
||||
credentialsId: 'CM',
|
||||
type: 'SOLMAN',
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
]
|
||||
@ -51,7 +53,11 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void changeDocumentIdNotProvidedTest() {
|
||||
public void changeDocumentIdNotProvidedSOLMANTest() {
|
||||
|
||||
// we expect the failure only for SOLMAN (which is the default).
|
||||
// Use case for CTS without change document id is checked by the
|
||||
// straight forward test case for CTS
|
||||
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId' or via commit history).")
|
||||
@ -91,7 +97,11 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applicationIdNotProvidedTest() {
|
||||
public void applicationIdNotProvidedSOLMANTest() {
|
||||
|
||||
// we expect the failure only for SOLMAN (which is the default).
|
||||
// Use case for CTS without applicationId is checked by the
|
||||
// straight forward test case for CTS
|
||||
|
||||
thrown.expect(IllegalArgumentException)
|
||||
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR applicationId")
|
||||
@ -112,7 +122,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
public void uploadFileToTransportRequestFailureTest() {
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
void uploadFileToTransportRequest(String changeId,
|
||||
void uploadFileToTransportRequest(BackendType type,
|
||||
String changeId,
|
||||
String transportRequestId,
|
||||
String applicationId,
|
||||
String filePath,
|
||||
@ -135,13 +146,14 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uploadFileToTransportRequestSuccessTest() {
|
||||
public void uploadFileToTransportRequestCTSSuccessTest() {
|
||||
|
||||
jlr.expect("[INFO] Uploading file '/path' to transport request '002' of change document '001'.")
|
||||
jlr.expect("[INFO] File '/path' has been successfully uploaded to transport request '002' of change document '001'.")
|
||||
jlr.expect("[INFO] Uploading file '/path' to transport request '002'.")
|
||||
jlr.expect("[INFO] File '/path' has been successfully uploaded to transport request '002'.")
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
void uploadFileToTransportRequest(String changeId,
|
||||
void uploadFileToTransportRequest(BackendType type,
|
||||
String changeId,
|
||||
String transportRequestId,
|
||||
String applicationId,
|
||||
String filePath,
|
||||
@ -149,6 +161,53 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
String credentialsId,
|
||||
String cmclientOpts) {
|
||||
|
||||
cmUtilReceivedParams.type = type
|
||||
cmUtilReceivedParams.changeId = changeId
|
||||
cmUtilReceivedParams.transportRequestId = transportRequestId
|
||||
cmUtilReceivedParams.applicationId = applicationId
|
||||
cmUtilReceivedParams.filePath = filePath
|
||||
cmUtilReceivedParams.endpoint = endpoint
|
||||
cmUtilReceivedParams.credentialsId = credentialsId
|
||||
cmUtilReceivedParams.cmclientOpts = cmclientOpts
|
||||
}
|
||||
}
|
||||
|
||||
jsr.step.call(script: nullScript,
|
||||
changeManagement: [type: 'CTS'],
|
||||
transportRequestId: '002',
|
||||
filePath: '/path',
|
||||
cmUtils: cm)
|
||||
|
||||
assert cmUtilReceivedParams ==
|
||||
[
|
||||
type: BackendType.CTS,
|
||||
changeId: null,
|
||||
transportRequestId: '002',
|
||||
applicationId: null,
|
||||
filePath: '/path',
|
||||
endpoint: 'https://example.org/cm',
|
||||
credentialsId: 'CM',
|
||||
cmclientOpts: ''
|
||||
]
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uploadFileToTransportRequestSOLMANSuccessTest() {
|
||||
|
||||
jlr.expect("[INFO] Uploading file '/path' to transport request '002' of change document '001'.")
|
||||
jlr.expect("[INFO] File '/path' has been successfully uploaded to transport request '002' of change document '001'.")
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
void uploadFileToTransportRequest(BackendType type,
|
||||
String changeId,
|
||||
String transportRequestId,
|
||||
String applicationId,
|
||||
String filePath,
|
||||
String endpoint,
|
||||
String credentialsId,
|
||||
String cmclientOpts) {
|
||||
|
||||
cmUtilReceivedParams.type = type
|
||||
cmUtilReceivedParams.changeId = changeId
|
||||
cmUtilReceivedParams.transportRequestId = transportRequestId
|
||||
cmUtilReceivedParams.applicationId = applicationId
|
||||
@ -168,6 +227,7 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
|
||||
assert cmUtilReceivedParams ==
|
||||
[
|
||||
type: BackendType.SOLMAN,
|
||||
changeId: '001',
|
||||
transportRequestId: '002',
|
||||
applicationId: 'app',
|
||||
@ -186,7 +246,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
[applicationId: 'AppIdfromConfig']]])
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
void uploadFileToTransportRequest(String changeId,
|
||||
void uploadFileToTransportRequest(BackendType type,
|
||||
String changeId,
|
||||
String transportRequestId,
|
||||
String applicationId,
|
||||
String filePath,
|
||||
@ -215,7 +276,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
nullScript.commonPipelineEnvironment.setMtarFilePath('/path2')
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
void uploadFileToTransportRequest(String changeId,
|
||||
void uploadFileToTransportRequest(BackendType type,
|
||||
String changeId,
|
||||
String transportRequestId,
|
||||
String applicationId,
|
||||
String filePath,
|
||||
@ -244,7 +306,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
nullScript.commonPipelineEnvironment.setMtarFilePath('/path2')
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
void uploadFileToTransportRequest(String changeId,
|
||||
void uploadFileToTransportRequest(BackendType type,
|
||||
String changeId,
|
||||
String transportRequestId,
|
||||
String applicationId,
|
||||
String filePath,
|
||||
@ -272,7 +335,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
thrown.expectMessage('Upload failure.')
|
||||
|
||||
ChangeManagement cm = new ChangeManagement(nullScript) {
|
||||
void uploadFileToTransportRequest(String changeId,
|
||||
void uploadFileToTransportRequest(BackendType type,
|
||||
String changeId,
|
||||
String transportRequestId,
|
||||
String applicationId,
|
||||
String filePath,
|
||||
@ -291,4 +355,26 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
||||
cmUtils: cm)
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidBackendTypeTest() {
|
||||
thrown.expect(AbortException)
|
||||
thrown.expectMessage('Invalid backend type: \'DUMMY\'. Valid values: [SOLMAN, CTS, NONE]. ' +
|
||||
'Configuration: \'changeManagement/type\'.')
|
||||
|
||||
jsr.step.call(script: nullScript,
|
||||
applicationId: 'app',
|
||||
filePath: '/path',
|
||||
changeManagement: [type: 'DUMMY'])
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cmIntegrationSwichtedOffTest() {
|
||||
|
||||
jlr.expect('[INFO] Change management integration intentionally switched off.')
|
||||
|
||||
jsr.step.call(
|
||||
changeManagement: [type: 'NONE'])
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -130,7 +130,8 @@ public class ChangeManagementTest extends BasePiperTest {
|
||||
@Test
|
||||
public void testGetCommandLineWithoutCMClientOpts() {
|
||||
String commandLine = new ChangeManagement(nullScript, null)
|
||||
.getCMCommandLine('https://example.org/cm',
|
||||
.getCMCommandLine(BackendType.SOLMAN,
|
||||
'https://example.org/cm',
|
||||
"me",
|
||||
"topSecret",
|
||||
"the-command",
|
||||
@ -143,7 +144,8 @@ public class ChangeManagementTest extends BasePiperTest {
|
||||
@Test
|
||||
public void testGetCommandLineWithCMClientOpts() {
|
||||
String commandLine = new ChangeManagement(nullScript, null)
|
||||
.getCMCommandLine('https://example.org/cm',
|
||||
.getCMCommandLine(BackendType.SOLMAN,
|
||||
'https://example.org/cm',
|
||||
"me",
|
||||
"topSecret",
|
||||
"the-command",
|
||||
@ -154,10 +156,28 @@ public void testGetCommandLineWithCMClientOpts() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateTransportRequestSucceeds() {
|
||||
public void testCreateTransportRequestSOLMANSucceeds() {
|
||||
|
||||
script.setReturnValue(JenkinsShellCallRule.Type.REGEX, ".*cmclient.*create-transport -cID 001 -dID 002.*", '004')
|
||||
def transportRequestId = new ChangeManagement(nullScript).createTransportRequest('001', '002', '003', 'me')
|
||||
def transportRequestId = new ChangeManagement(nullScript).createTransportRequestSOLMAN( '001', '002', '003', 'me')
|
||||
|
||||
// the check for the transportRequestID is sufficient. This checks implicit the command line since that value is
|
||||
// returned only in case the shell call matches.
|
||||
assert transportRequestId == '004'
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateTransportRequestCTSSucceeds() {
|
||||
|
||||
script.setReturnValue(JenkinsShellCallRule.Type.REGEX, 'cmclient.* -t CTS .*create-transport -tt W -ts XYZ -d "desc 123"$', '004')
|
||||
def transportRequestId = new ChangeManagement(nullScript)
|
||||
.createTransportRequestCTS(
|
||||
'W', // transport type
|
||||
'XYZ', // target system
|
||||
'desc 123', // description
|
||||
'https://example.org/cm',
|
||||
'me')
|
||||
|
||||
// the check for the transportRequestID is sufficient. This checks implicit the command line since that value is
|
||||
// returned only in case the shell call matches.
|
||||
@ -174,7 +194,8 @@ public void testGetCommandLineWithCMClientOpts() {
|
||||
thrown.expectMessage('Cannot upload file \'/path\' for change document \'001\''+
|
||||
' with transport request \'002\'. Return code from cmclient: 1.')
|
||||
|
||||
new ChangeManagement(nullScript).uploadFileToTransportRequest('001',
|
||||
new ChangeManagement(nullScript).uploadFileToTransportRequest(BackendType.SOLMAN,
|
||||
'001',
|
||||
'002',
|
||||
'XXX',
|
||||
'/path',
|
||||
@ -183,12 +204,14 @@ public void testGetCommandLineWithCMClientOpts() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadFileToTransportSucceeds() {
|
||||
public void testUploadFileToTransportSucceedsSOLMAN() {
|
||||
|
||||
// the regex provided below is an implicit check that the command line is fine.
|
||||
script.setReturnValue(JenkinsShellCallRule.Type.REGEX,, 'upload-file-to-transport.*-cID 001 -tID 002 XXX "/path"', 0)
|
||||
script.setReturnValue(JenkinsShellCallRule.Type.REGEX, 'upload-file-to-transport.*-cID 001 -tID 002 XXX "/path"', 0)
|
||||
|
||||
new ChangeManagement(nullScript).uploadFileToTransportRequest('001',
|
||||
new ChangeManagement(nullScript).uploadFileToTransportRequest(
|
||||
BackendType.SOLMAN,
|
||||
'001',
|
||||
'002',
|
||||
'XXX',
|
||||
'/path',
|
||||
@ -199,6 +222,25 @@ public void testGetCommandLineWithCMClientOpts() {
|
||||
// the command line.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadFileToTransportSucceedsCTS() {
|
||||
|
||||
// the regex provided below is an implicit check that the command line is fine.
|
||||
script.setReturnValue(JenkinsShellCallRule.Type.REGEX, '-t CTS upload-file-to-transport -tID 002 "/path"', 0)
|
||||
|
||||
new ChangeManagement(nullScript).uploadFileToTransportRequest(
|
||||
BackendType.CTS,
|
||||
null,
|
||||
'002',
|
||||
null,
|
||||
'/path',
|
||||
'https://example.org/cm',
|
||||
'me')
|
||||
|
||||
// no assert required here, since the regex registered above to the script rule is an implicit check for
|
||||
// the command line.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadFileToTransportFails() {
|
||||
|
||||
@ -208,7 +250,8 @@ public void testGetCommandLineWithCMClientOpts() {
|
||||
|
||||
script.setReturnValue(JenkinsShellCallRule.Type.REGEX,, 'upload-file-to-transport', 1)
|
||||
|
||||
new ChangeManagement(nullScript).uploadFileToTransportRequest('001',
|
||||
new ChangeManagement(nullScript).uploadFileToTransportRequest(BackendType.SOLMAN,
|
||||
'001',
|
||||
'002',
|
||||
'XXX',
|
||||
'/path',
|
||||
@ -217,12 +260,32 @@ public void testGetCommandLineWithCMClientOpts() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReleaseTransportRequestSucceeds() {
|
||||
public void testReleaseTransportRequestSucceedsSOLMAN() {
|
||||
|
||||
// the regex provided below is an implicit check that the command line is fine.
|
||||
script.setReturnValue(JenkinsShellCallRule.Type.REGEX, 'release-transport.*-cID 001.*-tID 002', 0)
|
||||
script.setReturnValue(JenkinsShellCallRule.Type.REGEX, '-t SOLMAN release-transport.*-cID 001.*-tID 002', 0)
|
||||
|
||||
new ChangeManagement(nullScript).releaseTransportRequest('001',
|
||||
new ChangeManagement(nullScript).releaseTransportRequest(
|
||||
BackendType.SOLMAN,
|
||||
'001',
|
||||
'002',
|
||||
'https://example.org',
|
||||
'me',
|
||||
'openSesame')
|
||||
|
||||
// no assert required here, since the regex registered above to the script rule is an implicit check for
|
||||
// the command line.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReleaseTransportRequestSucceedsCTS() {
|
||||
|
||||
// the regex provided below is an implicit check that the command line is fine.
|
||||
script.setReturnValue(JenkinsShellCallRule.Type.REGEX, '-t CTS export-transport.*-tID 002', 0)
|
||||
|
||||
new ChangeManagement(nullScript).releaseTransportRequest(
|
||||
BackendType.CTS,
|
||||
null,
|
||||
'002',
|
||||
'https://example.org',
|
||||
'me',
|
||||
@ -241,7 +304,9 @@ public void testGetCommandLineWithCMClientOpts() {
|
||||
// the regex provided below is an implicit check that the command line is fine.
|
||||
script.setReturnValue(JenkinsShellCallRule.Type.REGEX, 'release-transport.*-cID 001.*-tID 002', 1)
|
||||
|
||||
new ChangeManagement(nullScript).releaseTransportRequest('001',
|
||||
new ChangeManagement(nullScript).releaseTransportRequest(
|
||||
BackendType.SOLMAN,
|
||||
'001',
|
||||
'002',
|
||||
'https://example.org',
|
||||
'me',
|
||||
|
@ -5,9 +5,12 @@ import hudson.AbortException
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.ConfigurationMerger
|
||||
import com.sap.piper.cm.BackendType
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
@Field def STEP_NAME = 'checkChangeInDevelopment'
|
||||
|
||||
@Field Set stepConfigurationKeys = [
|
||||
@ -35,6 +38,15 @@ void call(parameters = [:]) {
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
BackendType backendType = getBackendTypeAndLogInfoIfCMIntegrationDisabled(this, configuration)
|
||||
if(backendType == BackendType.NONE) return
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
configHelper
|
||||
// for the following parameters we expect defaults
|
||||
.withMandatoryProperty('changeManagement/changeDocumentLabel')
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
@ -47,10 +59,6 @@ void call(parameters = [:]) {
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
def changeId = configuration.changeDocumentId
|
||||
|
||||
if(changeId?.trim()) {
|
||||
|
@ -2,17 +2,22 @@ import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.cm.BackendType
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
import hudson.AbortException
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestCreate'
|
||||
|
||||
@Field Set stepConfigurationKeys = [
|
||||
'changeManagement',
|
||||
'developmentSystemId'
|
||||
'description', // CTS
|
||||
'developmentSystemId', // SOLMAN
|
||||
'targetSystem', // CTS
|
||||
'transportType', // CTS
|
||||
]
|
||||
|
||||
@Field Set parameterKeys = stepConfigurationKeys.plus(['changeDocumentId'])
|
||||
@ -35,57 +40,89 @@ def call(parameters = [:]) {
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
BackendType backendType = getBackendTypeAndLogInfoIfCMIntegrationDisabled(this, configuration)
|
||||
if(backendType == BackendType.NONE) return
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
configHelper
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
.withMandatoryProperty('changeManagement/credentialsId')
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
.withMandatoryProperty('changeManagement/git/from')
|
||||
.withMandatoryProperty('changeManagement/git/to')
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
.withMandatoryProperty('developmentSystemId')
|
||||
.withMandatoryProperty('transportType', null, { backendType == BackendType.CTS})
|
||||
.withMandatoryProperty('targetSystem', null, { backendType == BackendType.CTS})
|
||||
.withMandatoryProperty('description', null, { backendType == BackendType.CTS})
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
def changeDocumentId = null
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
if(changeDocumentId?.trim()) {
|
||||
if(changeDocumentId?.trim()) {
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
try {
|
||||
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.changeDocumentLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
configHelper.mixin([changeDocumentId: changeDocumentId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
.withMandatoryProperty('developmentSystemId')
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
"Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
|
||||
}
|
||||
|
||||
configuration = configHelper.mixin([changeDocumentId: changeDocumentId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
"Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
|
||||
.use()
|
||||
configuration = configHelper.use()
|
||||
|
||||
echo "[INFO] Creating transport request for change document '${configuration.changeDocumentId}' and development system '${configuration.developmentSystemId}'."
|
||||
def creatingMessage = ["[INFO] Creating transport request"]
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
creatingMessage << " for change document '${configuration.changeDocumentId}' and development system '${configuration.developmentSystemId}'"
|
||||
}
|
||||
creatingMessage << '.'
|
||||
echo creatingMessage.join()
|
||||
|
||||
try {
|
||||
transportRequestId = cm.createTransportRequest(configuration.changeDocumentId,
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
transportRequestId = cm.createTransportRequestSOLMAN(
|
||||
configuration.changeDocumentId,
|
||||
configuration.developmentSystemId,
|
||||
configuration.changeManagement.endpoint,
|
||||
configuration.changeManagement.credentialsId,
|
||||
configuration.changeManagement.clientOpts)
|
||||
} else if(backendType == BackendType.CTS) {
|
||||
transportRequestId = cm.createTransportRequestCTS(
|
||||
configuration.transportType,
|
||||
configuration.targetSystem,
|
||||
configuration.description,
|
||||
configuration.changeManagement.endpoint,
|
||||
configuration.changeManagement.credentialsId,
|
||||
configuration.changeManagement.clientOpts)
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid backend type: '${backendType}'.")
|
||||
}
|
||||
} catch(ChangeManagementException ex) {
|
||||
throw new AbortException(ex.getMessage())
|
||||
}
|
||||
|
@ -2,11 +2,13 @@ import com.sap.piper.Utils
|
||||
import groovy.transform.Field
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.cm.BackendType
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestRelease'
|
||||
|
||||
@ -35,6 +37,14 @@ void call(parameters = [:]) {
|
||||
.mixinStepConfig(script.commonPipelineEnvironment, stepConfigurationKeys)
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
BackendType backendType = getBackendTypeAndLogInfoIfCMIntegrationDisabled(this, configuration)
|
||||
if(backendType == BackendType.NONE) return
|
||||
|
||||
configHelper
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
.withMandatoryProperty('changeManagement/credentialsId')
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
@ -42,8 +52,6 @@ void call(parameters = [:]) {
|
||||
.withMandatoryProperty('changeManagement/git/from')
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
|
||||
def transportRequestId = configuration.transportRequestId
|
||||
@ -72,45 +80,56 @@ void call(parameters = [:]) {
|
||||
}
|
||||
}
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
def changeDocumentId = null
|
||||
|
||||
if(changeDocumentId?.trim()) {
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
} else {
|
||||
if(changeDocumentId?.trim()) {
|
||||
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
|
||||
try {
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.changeDocumentLabel,
|
||||
configuration.changeManagement.gitformat
|
||||
)
|
||||
} else {
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
try {
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.changeDocumentLabel,
|
||||
configuration.changeManagement.gitformat
|
||||
)
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
|
||||
configHelper.mixin([changeDocumentId: changeDocumentId?.trim() ?: null], ['changeDocumentId'] as Set)
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
"Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
|
||||
|
||||
}
|
||||
|
||||
configuration = configHelper
|
||||
.mixin([transportRequestId: transportRequestId?.trim() ?: null,
|
||||
changeDocumentId: changeDocumentId?.trim() ?: null], ['transportRequestId', 'changeDocumentId'] as Set)
|
||||
.mixin([transportRequestId: transportRequestId?.trim() ?: null], ['transportRequestId'] as Set)
|
||||
.withMandatoryProperty('transportRequestId',
|
||||
"Transport request id not provided (parameter: \'transportRequestId\' or via commit history).")
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
"Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
|
||||
.use()
|
||||
|
||||
echo "[INFO] Closing transport request '${configuration.transportRequestId}' for change document '${configuration.changeDocumentId}'."
|
||||
def closingMessage = ["[INFO] Closing transport request '${configuration.transportRequestId}'"]
|
||||
if(backendType == BackendType.SOLMAN) closingMessage << " for change document '${configuration.changeDocumentId}'"
|
||||
closingMessage << '.'
|
||||
echo closingMessage.join()
|
||||
|
||||
try {
|
||||
cm.releaseTransportRequest(configuration.changeDocumentId,
|
||||
cm.releaseTransportRequest(backendType,
|
||||
configuration.changeDocumentId,
|
||||
configuration.transportRequestId,
|
||||
configuration.changeManagement.endpoint,
|
||||
configuration.changeManagement.credentialsId,
|
||||
|
@ -3,10 +3,12 @@ import groovy.transform.Field
|
||||
|
||||
import com.sap.piper.ConfigurationHelper
|
||||
import com.sap.piper.cm.ChangeManagement
|
||||
import com.sap.piper.cm.BackendType
|
||||
import com.sap.piper.cm.ChangeManagementException
|
||||
|
||||
import hudson.AbortException
|
||||
|
||||
import static com.sap.piper.cm.StepHelpers.getBackendTypeAndLogInfoIfCMIntegrationDisabled
|
||||
|
||||
@Field def STEP_NAME = 'transportRequestUploadFile'
|
||||
|
||||
@ -38,43 +40,53 @@ void call(parameters = [:]) {
|
||||
.mixinStageConfig(script.commonPipelineEnvironment, parameters.stageName?:env.STAGE_NAME, stepConfigurationKeys)
|
||||
.mixin(parameters, parameterKeys)
|
||||
.addIfEmpty('filePath', script.commonPipelineEnvironment.getMtarFilePath())
|
||||
.withMandatoryProperty('applicationId')
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
|
||||
BackendType backendType = getBackendTypeAndLogInfoIfCMIntegrationDisabled(this, configuration)
|
||||
if(backendType == BackendType.NONE) return
|
||||
|
||||
configHelper
|
||||
.withMandatoryProperty('changeManagement/changeDocumentLabel')
|
||||
.withMandatoryProperty('changeManagement/clientOpts')
|
||||
.withMandatoryProperty('changeManagement/credentialsId')
|
||||
.withMandatoryProperty('changeManagement/endpoint')
|
||||
.withMandatoryProperty('changeManagement/type')
|
||||
.withMandatoryProperty('changeManagement/git/from')
|
||||
.withMandatoryProperty('changeManagement/git/to')
|
||||
.withMandatoryProperty('changeManagement/git/format')
|
||||
.withMandatoryProperty('filePath')
|
||||
|
||||
Map configuration = configHelper.use()
|
||||
new Utils().pushToSWA([step: STEP_NAME, stepParam1: configuration.changeManagement.type], configuration)
|
||||
|
||||
new Utils().pushToSWA([step: STEP_NAME], configuration)
|
||||
def changeDocumentId = null
|
||||
|
||||
def changeDocumentId = configuration.changeDocumentId
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
|
||||
if(changeDocumentId?.trim()) {
|
||||
changeDocumentId = configuration.changeDocumentId
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
if(changeDocumentId?.trim()) {
|
||||
|
||||
} else {
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from parameters."
|
||||
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeManagement.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
} else {
|
||||
|
||||
try {
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.changeDocumentLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeManagement.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
try {
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
configuration.changeManagement.git.from,
|
||||
configuration.changeManagement.git.to,
|
||||
configuration.changeManagement.changeDocumentLabel,
|
||||
configuration.changeManagement.git.format
|
||||
)
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
echo "[INFO] ChangeDocumentId '${changeDocumentId}' retrieved from commit history"
|
||||
|
||||
} catch(ChangeManagementException ex) {
|
||||
echo "[WARN] Cannot retrieve changeDocumentId from commit history: ${ex.getMessage()}."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,21 +116,33 @@ void call(parameters = [:]) {
|
||||
}
|
||||
}
|
||||
|
||||
configHelper
|
||||
.mixin([changeDocumentId: changeDocumentId?.trim() ?: null,
|
||||
transportRequestId: transportRequestId?.trim() ?: null], ['changeDocumentId', 'transportRequestId'] as Set)
|
||||
|
||||
if(backendType == BackendType.SOLMAN) {
|
||||
configHelper
|
||||
.withMandatoryProperty('changeDocumentId',
|
||||
"Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
|
||||
.withMandatoryProperty('applicationId')
|
||||
}
|
||||
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',
|
||||
.withMandatoryProperty('transportRequestId',
|
||||
"Transport request id not provided (parameter: \'transportRequestId\' or via commit history).")
|
||||
.use()
|
||||
|
||||
echo "[INFO] Uploading file '${configuration.filePath}' to transport request '${configuration.transportRequestId}' of change document '${configuration.changeDocumentId}'."
|
||||
def uploadingMessage = ["[INFO] Uploading file '${configuration.filePath}' to transport request '${configuration.transportRequestId}'"]
|
||||
if(backendType == BackendType.SOLMAN)
|
||||
uploadingMessage << " of change document '${configuration.changeDocumentId}'"
|
||||
uploadingMessage << '.'
|
||||
|
||||
echo uploadingMessage.join()
|
||||
|
||||
try {
|
||||
|
||||
|
||||
cm.uploadFileToTransportRequest(configuration.changeDocumentId,
|
||||
cm.uploadFileToTransportRequest(backendType,
|
||||
configuration.changeDocumentId,
|
||||
configuration.transportRequestId,
|
||||
configuration.applicationId,
|
||||
configuration.filePath,
|
||||
@ -131,6 +155,10 @@ void call(parameters = [:]) {
|
||||
}
|
||||
|
||||
|
||||
echo "[INFO] File '${configuration.filePath}' has been successfully uploaded to transport request '${configuration.transportRequestId}' of change document '${configuration.changeDocumentId}'."
|
||||
def uploadedMessage = ["[INFO] File '${configuration.filePath}' has been successfully uploaded to transport request '${configuration.transportRequestId}'"]
|
||||
if(backendType == BackendType.SOLMAN)
|
||||
uploadedMessage << " of change document '${configuration.changeDocumentId}'"
|
||||
uploadedMessage << '.'
|
||||
echo uploadedMessage.join()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user