1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-25 21:39:13 +02:00

ABAPEnvironmentPipeline: move cloudFoundryCreateServiceKey (#3712)

* Move cloudFoundryCreateServiceKey

* Adapt tests

* Update defaults

* Fix Unittest

* Fix test

* Adapt test

* Fix

* Adapt
This commit is contained in:
Daniel Mieg 2022-05-03 12:52:44 +02:00 committed by GitHub
parent 7ad96ee686
commit 3f54eb74bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 31 additions and 33 deletions

View File

@ -9,8 +9,8 @@ You can have a look at different pipeline configurations in our [SAP-samples rep
|--------------------------|-------|
| Init | - |
| [Initial Checks](stages/initialChecks.md) | [abapAddonAssemblyKitCheckPV](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCheckPV/), [abapAddonAssemblyKitCheckCVs](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCheckCVs/), [abapAddonAssemblyKitReserveNextPackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitReserveNextPackages/),|
| [Prepare System](stages/prepareSystem.md) | [abapEnvironmentCreateSystem](https://sap.github.io/jenkins-library/steps/abapEnvironmentCreateSystem/), [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/)|
| [Clone Repositories](stages/cloneRepositories.md) | [abapEnvironmentPullGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentPullGitRepo/), [abapEnvironmentCloneGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentCloneGitRepo/), [abapEnvironmentCheckoutBranch](https://sap.github.io/jenkins-library/steps/abapEnvironmentCheckoutBranch/)|
| [Prepare System](stages/prepareSystem.md) | [abapEnvironmentCreateSystem](https://sap.github.io/jenkins-library/steps/abapEnvironmentCreateSystem/) |
| [Clone Repositories](stages/cloneRepositories.md) | [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/), [abapEnvironmentPullGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentPullGitRepo/), [abapEnvironmentCloneGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentCloneGitRepo/), [abapEnvironmentCheckoutBranch](https://sap.github.io/jenkins-library/steps/abapEnvironmentCheckoutBranch/)|
| [Test](stages/test.md) | [abapEnvironmentRunATCCheck](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunATCCheck/), [abapEnvironmentRunAUnitTest](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunAUnitTest/), [abapEnvironmentPushATCSystemConfig](https://sap.github.io/jenkins-library/steps/abapEnvironmentPushATCSystemConfig/)|
| [Build](stages/build.md) | [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/), [abapEnvironmentAssemblePackages](https://sap.github.io/jenkins-library/steps/abapEnvironmentAssemblePackages/), [abapAddonAssemblyKitRegisterPackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitRegisterPackages/), [abapAddonAssemblyKitReleasePackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitReleasePackages/), [abapEnvironmentAssembleConfirm](https://sap.github.io/jenkins-library/steps/abapEnvironmentAssembleConfirm/), [abapAddonAssemblyKitCreateTargetVector](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCreateTargetVector/), [abapAddonAssemblyKitPublishTargetVector](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitPublishTargetVector/)|
| [Integration Tests](stages/integrationTest.md) | [abapEnvironmentCreateSystem](https://sap.github.io/jenkins-library/steps/abapEnvironmentCreateSystem/), [cloudFoundryDeleteService](https://sap.github.io/jenkins-library/steps/cloudFoundryDeleteService/)|

View File

@ -25,8 +25,8 @@ The following stages and steps are part of the pipeline:
|--------------------------|-------|
| Init | - |
| [Initial Checks](stages/initialChecks.md) | [abapAddonAssemblyKitCheckPV](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCheckPV/), [abapAddonAssemblyKitCheckCVs](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCheckCVs/)|
| [Prepare System](stages/prepareSystem.md) | [abapEnvironmentCreateSystem](https://sap.github.io/jenkins-library/steps/abapEnvironmentCreateSystem/), [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/)|
| [Clone Repositories](stages/cloneRepositories.md) | [abapEnvironmentPullGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentPullGitRepo/)|
| [Prepare System](stages/prepareSystem.md) | [abapEnvironmentCreateSystem](https://sap.github.io/jenkins-library/steps/abapEnvironmentCreateSystem/) |
| [Clone Repositories](stages/cloneRepositories.md) | [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/), [abapEnvironmentPullGitRepo](https://sap.github.io/jenkins-library/steps/abapEnvironmentPullGitRepo/)|
| [Test](stages/test.md) | [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/), [abapEnvironmentRunATCCheck](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunATCCheck/), [abapEnvironmentRunAUnitTest](https://sap.github.io/jenkins-library/steps/abapEnvironmentRunAUnitTest/) |
| [Build](stages/build.md) | [cloudFoundryCreateServiceKey](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateServiceKey/), [abapAddonAssemblyKitReserveNextPackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitReserveNextPackages/), [abapEnvironmentAssemblePackages](https://sap.github.io/jenkins-library/steps/abapEnvironmentAssemblePackages/), [abapAddonAssemblyKitRegisterPackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitRegisterPackages/), [abapEnvironmentAssembleConfirm](https://sap.github.io/jenkins-library/steps/abapEnvironmentAssembleConfirm/), [abapAddonAssemblyKitReleasePackages](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitReleasePackages/), [abapAddonAssemblyKitCreateTargetVector](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitCreateTargetVector/), [abapAddonAssemblyKitPublishTargetVector](https://sap.github.io/jenkins-library/steps/abapAddonAssemblyKitPublishTargetVector/)|
| [Integration Tests](stages/integrationTest.md) | [cloudFoundryCreateService](https://sap.github.io/jenkins-library/steps/cloudFoundryCreateService/)|

View File

@ -1,11 +1,12 @@
# Clone Repositories
This stage creates pulls/clones the specified software components (repositories) to the SAP BTP, ABAP environment system.
This stage creates pulls/clones the specified software components (repositories) to the SAP BTP, ABAP environment system. As a prerequisite, the Communication Arrangement [SAP_COM_0510](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/b04a9ae412894725a2fc539bfb1ca055.html) (SAP BTP, ABAP Environment - Software Component Test Integration) is created using the step `cloudFoundryCreateServiceKey`. With the creation of the Communication Arrangement, a User and Password is created on the SAP BTP, ABAP environment system for the APIs that are used in this stage, as well as in the ATC stage.
## Steps
The following steps can be executed in this stage:
- [cloudFoundryCreateServiceKey](../../../steps/cloudFoundryCreateServiceKey.md)
- [abapEnvironmentPullGitRepo](../../../steps/abapEnvironmentPullGitRepo.md)
- [abapEnvironmentCloneGitRepo](../../../steps/abapEnvironmentCloneGitRepo.md)
- [abapEnvironmentCheckoutBranch](../../../steps/abapEnvironmentCheckoutBranch.md)
@ -37,7 +38,6 @@ general:
cfSpace: 'mySpace'
cfCredentialsId: 'cfAuthentification'
cfServiceInstance: 'abap_system'
cfServiceKeyName: 'JENKINS_SAP_COM_0510'
stages:
Clone Repositories:
repositories: 'repositories.yml'

View File

@ -1,13 +1,12 @@
# Prepare System
In this stage, the SAP BTP, ABAP environment system is created. This is done with the `abapEnvironmentCreateSystem` step. After the system creation, the Communication Arrangement [SAP_COM_0510](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/b04a9ae412894725a2fc539bfb1ca055.html) (SAP BTP, ABAP Environment - Software Component Test Integration) is created using the step `cloudFoundryCreateServiceKey`. With the creation of the Communication Arrangement, a User and Password is created on the SAP BTP, ABAP environment system for the APIs that are used in the following stages.
In this stage, the SAP BTP, ABAP environment system is created. This is done with the `abapEnvironmentCreateSystem` step.
## Steps
The following steps are executed in this stage:
- [abapEnvironmentCreateSystem](../../../steps/abapEnvironmentCreateSystem.md)
- [cloudFoundryCreateServiceKey](../../../steps/cloudFoundryCreateServiceKey.md)
## Stage Parameters
@ -28,7 +27,6 @@ general:
cfSpace: 'mySpace'
cfCredentialsId: 'cfAuthentification'
cfServiceInstance: 'abap_system'
cfServiceKeyName: 'JENKINS_SAP_COM_0510'
stages:
Prepare System:
cfService: 'abap'
@ -39,14 +37,4 @@ stages:
abapSystemID: 'H02'
abapSystemSizeOfPersistence: 4
abapSystemSizeOfRuntime: 1
cfServiceKeyConfig: 'serviceKey.json'
```
### serviceKey.json
```json
{
"scenario_id": "SAP_COM_0510",
"type": "basic"
}
```

View File

@ -13,10 +13,10 @@ stages:
abapSystemSizeOfPersistence: 4
abapSystemSizeOfRuntime: 1
cfServiceKeyName: 'sap_com_0510'
cfServiceKeyConfig: '{"scenario_id":"SAP_COM_0510","type":"basic"}'
'Clone Repositories':
cfServiceKeyName: 'sap_com_0510'
cfServiceKeyConfig: '{"scenario_id":"SAP_COM_0510","type":"basic"}'
ordinal: 30
'ATC':

View File

@ -23,7 +23,6 @@ class AbapEnvironmentPipelineStageCloneRepositoriesTest extends BasePiperTest {
.around(jsr)
private stepsCalled = []
@Before
void init() {
binding.variables.env.STAGE_NAME = 'Clone Repositories'
@ -35,18 +34,21 @@ class AbapEnvironmentPipelineStageCloneRepositoriesTest extends BasePiperTest {
helper.registerAllowedMethod('strategy', [Map], {m ->
stepsCalled.add('strategy')
})
helper.registerAllowedMethod('cloudFoundryCreateServiceKey', [Map.class], {m -> stepsCalled.add('cloudFoundryCreateServiceKey')})
helper.registerAllowedMethod('abapEnvironmentPullGitRepo', [Map.class], {m -> stepsCalled.add('abapEnvironmentPullGitRepo')})
helper.registerAllowedMethod('abapEnvironmentCheckoutBranch', [Map.class], {m -> stepsCalled.add('abapEnvironmentCheckoutBranch')})
helper.registerAllowedMethod('abapEnvironmentCloneGitRepo', [Map.class], {m -> stepsCalled.add('abapEnvironmentCloneGitRepo')})
// assertThat(stepsCalled, hasItem('cloudFoundryCreateServiceKey'))
}
@Test
void testAbapEnvironmentPipelineStageCloneRepositoriesPull() {
nullScript.commonPipelineEnvironment.configuration.runStage = []
jsr.step.abapEnvironmentPipelineStageCloneRepositories(script: nullScript, strategy: 'Pull')
jsr.step.abapEnvironmentPipelineStageCloneRepositories(script: nullScript, strategy: 'Pull', host: 'abc.com')
assertThat(stepsCalled, hasItems('abapEnvironmentPullGitRepo'))
assertThat(stepsCalled, not(hasItem('cloudFoundryCreateServiceKey')))
assertThat(stepsCalled, not(hasItems('abapEnvironmentCloneGitRepo')))
assertThat(stepsCalled, not(hasItems('abapEnvironmentCheckoutBranch')))
}
@ -57,7 +59,7 @@ class AbapEnvironmentPipelineStageCloneRepositoriesTest extends BasePiperTest {
nullScript.commonPipelineEnvironment.configuration.runStage = []
jsr.step.abapEnvironmentPipelineStageCloneRepositories(script: nullScript, strategy: 'Clone')
assertThat(stepsCalled, hasItems('abapEnvironmentCloneGitRepo'))
assertThat(stepsCalled, hasItems('abapEnvironmentCloneGitRepo', 'cloudFoundryCreateServiceKey'))
assertThat(stepsCalled, not(hasItems('abapEnvironmentPullGitRepo', 'abapEnvironmentCheckoutBranch')))
}
@ -67,7 +69,7 @@ class AbapEnvironmentPipelineStageCloneRepositoriesTest extends BasePiperTest {
nullScript.commonPipelineEnvironment.configuration.runStage = []
jsr.step.abapEnvironmentPipelineStageCloneRepositories(script: nullScript, strategy: 'CheckoutPull')
assertThat(stepsCalled, hasItems('abapEnvironmentPullGitRepo', 'abapEnvironmentCheckoutBranch'))
assertThat(stepsCalled, hasItems('abapEnvironmentPullGitRepo', 'abapEnvironmentCheckoutBranch', 'cloudFoundryCreateServiceKey'))
assertThat(stepsCalled, not(hasItems('abapEnvironmentCloneGitRepo')))
}
@ -75,9 +77,9 @@ class AbapEnvironmentPipelineStageCloneRepositoriesTest extends BasePiperTest {
void testAbapEnvironmentPipelineStageCloneRepositoriesPullCheckoutPull() {
nullScript.commonPipelineEnvironment.configuration.runStage = []
jsr.step.abapEnvironmentPipelineStageCloneRepositories(script: nullScript, strategy: 'AddonBuild')
jsr.step.abapEnvironmentPipelineStageCloneRepositories(script: nullScript, strategy: 'AddonBuild', host: 'abc.com')
assertThat(stepsCalled, not(hasItems('abapEnvironmentPullGitRepo', 'abapEnvironmentCheckoutBranch')))
assertThat(stepsCalled, not(hasItems('abapEnvironmentPullGitRepo', 'abapEnvironmentCheckoutBranch', 'cloudFoundryCreateServiceKey')))
assertThat(stepsCalled, hasItems('abapEnvironmentCloneGitRepo'))
}
@ -85,9 +87,9 @@ class AbapEnvironmentPipelineStageCloneRepositoriesTest extends BasePiperTest {
void testAbapEnvironmentPipelineStageCloneRepositoriesNoStrategy() {
nullScript.commonPipelineEnvironment.configuration.runStage = []
jsr.step.abapEnvironmentPipelineStageCloneRepositories(script: nullScript)
jsr.step.abapEnvironmentPipelineStageCloneRepositories(script: nullScript, host: 'abc.com')
assertThat(stepsCalled, hasItems('abapEnvironmentPullGitRepo'))
assertThat(stepsCalled, not(hasItems('abapEnvironmentCloneGitRepo', 'abapEnvironmentCheckoutBranch')))
assertThat(stepsCalled, not(hasItems('abapEnvironmentCloneGitRepo', 'abapEnvironmentCheckoutBranch', 'cloudFoundryCreateServiceKey')))
}
}

View File

@ -37,7 +37,6 @@ class AbapEnvironmentPipelineStagePrepareSystemTest extends BasePiperTest {
return null
})
helper.registerAllowedMethod('abapEnvironmentCreateSystem', [Map.class], {m -> stepsCalled.add('abapEnvironmentCreateSystem')})
helper.registerAllowedMethod('cloudFoundryCreateServiceKey', [Map.class], {m -> stepsCalled.add('cloudFoundryCreateServiceKey')})
}
@Test
@ -49,6 +48,5 @@ class AbapEnvironmentPipelineStagePrepareSystemTest extends BasePiperTest {
jsr.step.abapEnvironmentPipelineStagePrepareSystem(script: nullScript)
assertThat(stepsCalled, hasItem('abapEnvironmentCreateSystem'))
assertThat(stepsCalled, hasItem('cloudFoundryCreateServiceKey'))
}
}

View File

@ -11,12 +11,16 @@ import static com.sap.piper.Prerequisites.checkScript
@Field String STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = []
@Field STAGE_STEP_KEYS = [
/** Creates Communication Arrangements for ABAP Environment instance via the cloud foundry command line interface */
'cloudFoundryCreateServiceKey',
/** Starts an ATC check run on the ABAP Environment instance */
'abapEnvironmentRunATCCheck',
/** Creates/Updates ATC System Configuration */
'abapEnvironmentPushATCSystemConfig',
/** Parameter for ATC System Configuration json */
'atcSystemConfigFilePath'
'atcSystemConfigFilePath',
/** Parameter for host config */
'host'
]
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS

View File

@ -7,6 +7,8 @@ import static com.sap.piper.Prerequisites.checkScript
@Field String STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = []
@Field STAGE_STEP_KEYS = [
/** Creates Communication Arrangements for ABAP Environment instance via the cloud foundry command line interface */
'cloudFoundryCreateServiceKey',
/** Pulls Software Components / Git repositories into the ABAP Environment instance */
'abapEnvironmentPullGitRepo',
/** Checks out a Branch in the pulled Software Component on the ABAP Environment instance */
@ -14,7 +16,9 @@ import static com.sap.piper.Prerequisites.checkScript
/** Clones Software Components / Git repositories into the ABAP Environment instance and checks out the respective branches */
'abapEnvironmentCloneGitRepo',
/** Specifies the strategy that should be peformed on the ABAP Environment instance*/
'strategy'
'strategy',
/** Parameter for host config */
'host'
]
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
@ -34,6 +38,9 @@ void call(Map parameters = [:]) {
.use()
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
if (!config.host) {
cloudFoundryCreateServiceKey script: parameters.script
}
switch (config.strategy) {
case 'Pull':
abapEnvironmentPullGitRepo script: parameters.script

View File

@ -22,7 +22,6 @@ void call(Map parameters = [:]) {
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
abapEnvironmentCreateSystem script: parameters.script
cloudFoundryCreateServiceKey script: parameters.script
}
}