1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-02-21 19:48:53 +02:00
sap-jenkins-library/vars/abapEnvironmentPipelineStageIntegrationTests.groovy
ranliii f1234114be
Abap environment update addon product (#4774)
* new Piper step abapEnvironmentUpdateAddOnProduct

* modified entity json format and some minor function changes

* modified groovy file for pipelineStageIntTests and addonDescriptor to be mandatory in yaml file

* sync with fork branch ranliii/abap-environment-update-addon-product

* added generated file

* fail the step as long as addon update not successful and unit tests

* added docu for the new step

* tried to fix groovy unit test

* tried to fix groovy unit test 2

* for test

* fixed error

* fixed error 2

* tried to fix groovy unit test error

* added groovy unit test for new Piper step

* tried to fix groovy unit test error

* tried to fix groovy unit test error 2

* changes after first review

* remove .DS_Store

* for test

* revert test relevant changes

* try to fix groovy test error

* try to fix groovy error

* 3rd try to fix groovy test error

* rewrite the failed groovy test

* small changes and try with timeout as well as poll interval

* changes for test

* revert test-related changes

* try to fix errors

* Revert "Merge branch 'master' into abap-environment-update-addon-product"

This reverts commit 1ee0bcd80dd8ec58102ece31cacbe08bfd669ba1, reversing
changes made to 3c4a99dfb027ad561f0a52e888acaffb7be0053f.

* try to fix error

* try to fix error 2

* try to fix error 3

* align go.mod with master branch

* revert go.mod to commit 3c4a99d

* for test

* revert test changes

* new unit test

* Revert "Revert "Merge branch 'master' into abap-environment-update-addon-product""

This reverts commit 363c0380011e148231273d3f180dcec4d5cba88f.

* go generate after merging master

---------

Co-authored-by: Jk1484 <35270240+Jk1484@users.noreply.github.com>
Co-authored-by: Ran Li <ran.li01@sap.com>
Co-authored-by: tiloKo <70266685+tiloKo@users.noreply.github.com>
2024-02-20 19:39:43 +01:00

76 lines
3.4 KiB
Groovy

import groovy.transform.Field
import com.sap.piper.Utils
import com.sap.piper.ConfigurationHelper
import static com.sap.piper.Prerequisites.checkScript
@Field String STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = [
/** Creates a SAP BTP ABAP Environment system via the cloud foundry command line interface */
'abapEnvironmentCreateSystem',
/** Deletes a SAP BTP ABAP Environment system via the cloud foundry command line interface */
'cloudFoundryDeleteService',
/** If set to true, a confirmation is required to delete the system */
'confirmDeletion',
'debug', // If set to true, the system is never deleted
'testBuild', // Parameter for test execution mode, if true stage will be skipped
'integrationTestOption' // Integration test option
]
@Field Set STAGE_STEP_KEYS = GENERAL_CONFIG_KEYS
@Field Set STEP_CONFIG_KEYS = STAGE_STEP_KEYS
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* This stage creates a system for Integration Tests. The (custom) tests themselves can be added via a stage extension.
*/
void call(Map parameters = [:]) {
def script = checkScript(this, parameters) ?: this
def stageName = parameters.stageName?:env.STAGE_NAME
Map config = ConfigurationHelper.newInstance(this)
.loadStepDefaults()
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
.mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS)
.mixin(parameters, PARAMETER_KEYS)
.addIfEmpty('confirmDeletion', true)
.addIfEmpty('debug', false)
.addIfEmpty('testBuild', false)
.addIfEmpty('integrationTestOption', 'systemProvisioning')
.use()
if (config.testBuild) {
echo "Stage 'Integration Tests' skipped as parameter 'testBuild' is active"
return null;
}
piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
if (config.integrationTestOption == 'systemProvisioning') {
try {
abapEnvironmentCreateSystem(script: parameters.script, includeAddon: true)
cloudFoundryCreateServiceKey(script: parameters.script)
abapEnvironmentBuild(script: parameters.script, phase: 'GENERATION', downloadAllResultFiles: true, useFieldsOfAddonDescriptor: '[{"use":"Name","renameTo":"SWC"}]')
} catch (Exception e) {
echo "Deployment test of add-on product failed."
throw e
} finally {
if (!config.debug) {
cloudFoundryDeleteService script: parameters.script
}
}
} else if (config.integrationTestOption == 'addOnDeployment') {
try {
abapLandscapePortalUpdateAddOnProduct(script: parameters.script)
abapEnvironmentBuild(script: parameters.script, phase: 'GENERATION', downloadAllResultFiles: true, useFieldsOfAddonDescriptor: '[{"use":"Name","renameTo":"SWC"}]')
} catch (Exception e) {
echo "Deployment test of add-on product failed."
throw e
}
} else {
e = new Error('Unsupoorted integration test option.')
throw e
}
if (config.confirmDeletion) {
input message: "Deployment test has been executed. Once you proceed, the test system will be deleted."
}
}
}