mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Merge pull request #175 from alejandraferreirovidal/changeParameters
change credentialsId and endpoint
This commit is contained in:
commit
cc9332ae79
@ -11,19 +11,19 @@ Creates a Transport Request for a Change Document on the Solution Manager.
|
|||||||
| -----------------|-----------|--------------------------------------------------------|--------------------|
|
| -----------------|-----------|--------------------------------------------------------|--------------------|
|
||||||
| `script` | yes | | |
|
| `script` | yes | | |
|
||||||
| `changeDocumentId` | yes | | |
|
| `changeDocumentId` | yes | | |
|
||||||
| `cmCredentialsId` | yes | | |
|
| `credentialsId` | yes | | |
|
||||||
| `cmEndpoint` | yes | | |
|
| `endpoint` | yes | | |
|
||||||
|
|
||||||
* `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.
|
* `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.
|
* `changeDocumentId` - The id of the change document to transport.
|
||||||
* `cmCredentialsId` - The credentials to connect to the Solution Manager.
|
* `credentialsId` - The credentials to connect to the Solution Manager.
|
||||||
* `cmEndpoint` - The address of the Solution Manager.
|
* `endpoint` - The address of the Solution Manager.
|
||||||
|
|
||||||
## Step configuration
|
## Step configuration
|
||||||
The following parameters can also be specified as step parameters using the global configuration file:
|
The following parameters can also be specified as step parameters using the global configuration file:
|
||||||
|
|
||||||
* `cmCredentialsId`
|
* `credentialsId`
|
||||||
* `cmEndpoint`
|
* `endpoint`
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
The id of the Transport Request that has been created.
|
The id of the Transport Request that has been created.
|
||||||
|
@ -12,20 +12,20 @@ Releases a Transport Request for a Change Document on the Solution Manager.
|
|||||||
| `script` | yes | | |
|
| `script` | yes | | |
|
||||||
| `changeDocumentId` | yes | | |
|
| `changeDocumentId` | yes | | |
|
||||||
| `transportRequestId`| yes | | |
|
| `transportRequestId`| yes | | |
|
||||||
| `cmCredentialsId` | yes | | |
|
| `credentialsId` | yes | | |
|
||||||
| `cmEndpoint` | yes | | |
|
| `endpoint` | yes | | |
|
||||||
|
|
||||||
* `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.
|
* `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` - The id of the change document related to the transport request to release.
|
||||||
* `transportRequestId` - The id of the transport request to release.
|
* `transportRequestId` - The id of the transport request to release.
|
||||||
* `cmCredentialsId` - The credentials to connect to the Solution Manager.
|
* `credentialsId` - The credentials to connect to the Solution Manager.
|
||||||
* `cmEndpoint` - The address of the Solution Manager.
|
* `endpoint` - The address of the Solution Manager.
|
||||||
|
|
||||||
## Step configuration
|
## Step configuration
|
||||||
The following parameters can also be specified as step parameters using the global configuration file:
|
The following parameters can also be specified as step parameters using the global configuration file:
|
||||||
|
|
||||||
* `cmCredentialsId`
|
* `credentialsId`
|
||||||
* `cmEndpoint`
|
* `endpoint`
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
None.
|
None.
|
||||||
|
@ -14,22 +14,22 @@ Uploads a file to a Transport Request for a Change Document on the Solution Mana
|
|||||||
| `transportRequestId`| yes | | |
|
| `transportRequestId`| yes | | |
|
||||||
| `applicationId` | yes | | |
|
| `applicationId` | yes | | |
|
||||||
| `filePath` | yes | | |
|
| `filePath` | yes | | |
|
||||||
| `cmCredentialsId` | yes | | |
|
| `credentialsId` | yes | | |
|
||||||
| `cmEndpoint` | yes | | |
|
| `endpoint` | yes | | |
|
||||||
|
|
||||||
* `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.
|
* `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` - The id of the change document related to the transport request to release.
|
||||||
* `transportRequestId` - The id of the transport request to release.
|
* `transportRequestId` - The id of the transport request to release.
|
||||||
* `applicationId` - The id of the application.
|
* `applicationId` - The id of the application.
|
||||||
* `filePath` - The path of the file to upload.
|
* `filePath` - The path of the file to upload.
|
||||||
* `cmCredentialsId` - The credentials to connect to the Solution Manager.
|
* `credentialsId` - The credentials to connect to the Solution Manager.
|
||||||
* `cmEndpoint` - The address of the Solution Manager.
|
* `endpoint` - The address of the Solution Manager.
|
||||||
|
|
||||||
## Step configuration
|
## Step configuration
|
||||||
The following parameters can also be specified as step parameters using the global configuration file:
|
The following parameters can also be specified as step parameters using the global configuration file:
|
||||||
|
|
||||||
* `cmCredentialsId`
|
* `credentialsId`
|
||||||
* `cmEndpoint`
|
* `endpoint`
|
||||||
|
|
||||||
## Return value
|
## Return value
|
||||||
None.
|
None.
|
||||||
|
@ -47,8 +47,8 @@ public class TransportRequestCreateTest extends BasePiperTest {
|
|||||||
nullScript.commonPipelineEnvironment.configuration = [steps:
|
nullScript.commonPipelineEnvironment.configuration = [steps:
|
||||||
[transportRequestCreate:
|
[transportRequestCreate:
|
||||||
[
|
[
|
||||||
cmCredentialsId: 'CM',
|
credentialsId: 'CM',
|
||||||
cmEndpoint: 'https://example.org/cm'
|
endpoint: 'https://example.org/cm'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -47,8 +47,8 @@ public class TransportRequestReleaseTest extends BasePiperTest {
|
|||||||
nullScript.commonPipelineEnvironment.configuration = [steps:
|
nullScript.commonPipelineEnvironment.configuration = [steps:
|
||||||
[transportRequestRelease:
|
[transportRequestRelease:
|
||||||
[
|
[
|
||||||
cmCredentialsId: 'CM',
|
credentialsId: 'CM',
|
||||||
cmEndpoint: 'https://example.org/cm'
|
endpoint: 'https://example.org/cm'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -47,8 +47,8 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
|
|||||||
nullScript.commonPipelineEnvironment.configuration = [steps:
|
nullScript.commonPipelineEnvironment.configuration = [steps:
|
||||||
[transportRequestUploadFile:
|
[transportRequestUploadFile:
|
||||||
[
|
[
|
||||||
cmCredentialsId: 'CM',
|
credentialsId: 'CM',
|
||||||
cmEndpoint: 'https://example.org/cm'
|
endpoint: 'https://example.org/cm'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -13,13 +13,13 @@ import hudson.AbortException
|
|||||||
@Field Set parameterKeys = [
|
@Field Set parameterKeys = [
|
||||||
'changeDocumentId',
|
'changeDocumentId',
|
||||||
'developmentSystemId',
|
'developmentSystemId',
|
||||||
'cmCredentialsId',
|
'credentialsId',
|
||||||
'cmEndpoint'
|
'endpoint'
|
||||||
]
|
]
|
||||||
|
|
||||||
@Field Set stepConfigurationKeys = [
|
@Field Set stepConfigurationKeys = [
|
||||||
'cmCredentialsId',
|
'credentialsId',
|
||||||
'cmEndpoint'
|
'endpoint'
|
||||||
]
|
]
|
||||||
|
|
||||||
def call(parameters = [:]) {
|
def call(parameters = [:]) {
|
||||||
@ -40,23 +40,23 @@ def call(parameters = [:]) {
|
|||||||
def developmentSystemId = configuration.developmentSystemId
|
def developmentSystemId = configuration.developmentSystemId
|
||||||
if(!developmentSystemId) throw new AbortException('Development system id not provided (parameter: \'developmentSystemId\').')
|
if(!developmentSystemId) throw new AbortException('Development system id not provided (parameter: \'developmentSystemId\').')
|
||||||
|
|
||||||
def cmCredentialsId = configuration.cmCredentialsId
|
def credentialsId = configuration.credentialsId
|
||||||
if(!cmCredentialsId) throw new AbortException('Credentials id not provided (parameter: \'cmCredentialsId\').')
|
if(!credentialsId) throw new AbortException('Credentials id not provided (parameter: \'credentialsId\').')
|
||||||
|
|
||||||
def cmEndpoint = configuration.cmEndpoint
|
def endpoint = configuration.endpoint
|
||||||
if(!cmEndpoint) throw new AbortException('Solution Manager endpoint not provided (parameter: \'cmEndpoint\').')
|
if(!endpoint) throw new AbortException('Solution Manager endpoint not provided (parameter: \'endpoint\').')
|
||||||
|
|
||||||
def transportRequestId
|
def transportRequestId
|
||||||
|
|
||||||
echo "[INFO] Creating transport request for change document '$changeDocumentId' and development system '$developmentSystemId'."
|
echo "[INFO] Creating transport request for change document '$changeDocumentId' and development system '$developmentSystemId'."
|
||||||
|
|
||||||
withCredentials([usernamePassword(
|
withCredentials([usernamePassword(
|
||||||
credentialsId: cmCredentialsId,
|
credentialsId: credentialsId,
|
||||||
passwordVariable: 'password',
|
passwordVariable: 'password',
|
||||||
usernameVariable: 'username')]) {
|
usernameVariable: 'username')]) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
transportRequestId = cm.createTransportRequest(changeDocumentId, developmentSystemId, cmEndpoint, username, password)
|
transportRequestId = cm.createTransportRequest(changeDocumentId, developmentSystemId, endpoint, username, password)
|
||||||
} catch(ChangeManagementException ex) {
|
} catch(ChangeManagementException ex) {
|
||||||
throw new AbortException(ex.getMessage())
|
throw new AbortException(ex.getMessage())
|
||||||
}
|
}
|
||||||
|
@ -13,13 +13,13 @@ import hudson.AbortException
|
|||||||
@Field Set parameterKeys = [
|
@Field Set parameterKeys = [
|
||||||
'changeDocumentId',
|
'changeDocumentId',
|
||||||
'transportRequestId',
|
'transportRequestId',
|
||||||
'cmCredentialsId',
|
'credentialsId',
|
||||||
'cmEndpoint'
|
'endpoint'
|
||||||
]
|
]
|
||||||
|
|
||||||
@Field Set stepConfigurationKeys = [
|
@Field Set stepConfigurationKeys = [
|
||||||
'cmCredentialsId',
|
'credentialsId',
|
||||||
'cmEndpoint'
|
'endpoint'
|
||||||
]
|
]
|
||||||
|
|
||||||
def call(parameters = [:]) {
|
def call(parameters = [:]) {
|
||||||
@ -40,21 +40,21 @@ def call(parameters = [:]) {
|
|||||||
def transportRequestId = configuration.transportRequestId
|
def transportRequestId = configuration.transportRequestId
|
||||||
if(!transportRequestId) throw new AbortException("Transport Request id not provided (parameter: 'transportRequestId').")
|
if(!transportRequestId) throw new AbortException("Transport Request id not provided (parameter: 'transportRequestId').")
|
||||||
|
|
||||||
def cmCredentialsId = configuration.cmCredentialsId
|
def credentialsId = configuration.credentialsId
|
||||||
if(!cmCredentialsId) throw new AbortException("Credentials id not provided (parameter: 'cmCredentialsId').")
|
if(!credentialsId) throw new AbortException("Credentials id not provided (parameter: 'credentialsId').")
|
||||||
|
|
||||||
def cmEndpoint = configuration.cmEndpoint
|
def endpoint = configuration.endpoint
|
||||||
if(!cmEndpoint) throw new AbortException("Solution Manager endpoint not provided (parameter: 'cmEndpoint').")
|
if(!endpoint) throw new AbortException("Solution Manager endpoint not provided (parameter: 'endpoint').")
|
||||||
|
|
||||||
echo "[INFO] Closing transport request '$transportRequestId' for change document '$changeDocumentId'."
|
echo "[INFO] Closing transport request '$transportRequestId' for change document '$changeDocumentId'."
|
||||||
|
|
||||||
withCredentials([usernamePassword(
|
withCredentials([usernamePassword(
|
||||||
credentialsId: cmCredentialsId,
|
credentialsId: credentialsId,
|
||||||
passwordVariable: 'password',
|
passwordVariable: 'password',
|
||||||
usernameVariable: 'username')]) {
|
usernameVariable: 'username')]) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cm.releaseTransportRequest(changeDocumentId, transportRequestId, cmEndpoint, username, password)
|
cm.releaseTransportRequest(changeDocumentId, transportRequestId, endpoint, username, password)
|
||||||
} catch(ChangeManagementException ex) {
|
} catch(ChangeManagementException ex) {
|
||||||
throw new AbortException(ex.getMessage())
|
throw new AbortException(ex.getMessage())
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@ import hudson.AbortException
|
|||||||
'transportRequestId',
|
'transportRequestId',
|
||||||
'applicationId',
|
'applicationId',
|
||||||
'filePath',
|
'filePath',
|
||||||
'cmCredentialsId',
|
'credentialsId',
|
||||||
'cmEndpoint'
|
'endpoint'
|
||||||
]
|
]
|
||||||
|
|
||||||
@Field Set generalConfigurationKeys = [
|
@Field Set generalConfigurationKeys = [
|
||||||
'cmCredentialsId',
|
'credentialsId',
|
||||||
'cmEndpoint'
|
'endpoint'
|
||||||
]
|
]
|
||||||
|
|
||||||
def call(parameters = [:]) {
|
def call(parameters = [:]) {
|
||||||
@ -48,21 +48,21 @@ def call(parameters = [:]) {
|
|||||||
def filePath = configuration.filePath
|
def filePath = configuration.filePath
|
||||||
if(!filePath) throw new AbortException("File path not provided (parameter: 'filePath').")
|
if(!filePath) throw new AbortException("File path not provided (parameter: 'filePath').")
|
||||||
|
|
||||||
def cmCredentialsId = configuration.cmCredentialsId
|
def credentialsId = configuration.credentialsId
|
||||||
if(!cmCredentialsId) throw new AbortException("Credentials id not provided (parameter: 'cmCredentialsId').")
|
if(!credentialsId) throw new AbortException("Credentials id not provided (parameter: 'credentialsId').")
|
||||||
|
|
||||||
def cmEndpoint = configuration.cmEndpoint
|
def endpoint = configuration.endpoint
|
||||||
if(!cmEndpoint) throw new AbortException("Solution Manager endpoint not provided (parameter: 'cmEndpoint').")
|
if(!endpoint) throw new AbortException("Solution Manager endpoint not provided (parameter: 'endpoint').")
|
||||||
|
|
||||||
echo "[INFO] Uploading file '$filePath' to transport request '$transportRequestId' of change document '$changeDocumentId'."
|
echo "[INFO] Uploading file '$filePath' to transport request '$transportRequestId' of change document '$changeDocumentId'."
|
||||||
|
|
||||||
withCredentials([usernamePassword(
|
withCredentials([usernamePassword(
|
||||||
credentialsId: cmCredentialsId,
|
credentialsId: credentialsId,
|
||||||
passwordVariable: 'password',
|
passwordVariable: 'password',
|
||||||
usernameVariable: 'username')]) {
|
usernameVariable: 'username')]) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cm.uploadFileToTransportRequest(changeDocumentId, transportRequestId, applicationId, filePath, cmEndpoint, username, password)
|
cm.uploadFileToTransportRequest(changeDocumentId, transportRequestId, applicationId, filePath, endpoint, username, password)
|
||||||
} catch(ChangeManagementException ex) {
|
} catch(ChangeManagementException ex) {
|
||||||
throw new AbortException(ex.getMessage())
|
throw new AbortException(ex.getMessage())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user