1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/vars/piperPipelineStageIntegration.groovy
Kevin Hudemann ce96c379ef
Add mavenExecuteIntegration and writeTemporaryCredentials to piperPipelineStageIntegration (#1927)
This change add the support for running integration tests using the
recently introduced step mavenExecuteIntegration in
piperPipelineStageIntegration. In addition, capabilities to provide
temporary credentials to these tests is added using the
writeTemporaryCredentials step.
2020-08-14 15:22:05 +02:00

68 lines
2.5 KiB
Groovy

import com.sap.piper.ConfigurationHelper
import com.sap.piper.GenerateStageDocumentation
import com.sap.piper.Utils
import groovy.transform.Field
import static com.sap.piper.Prerequisites.checkScript
@Field String STEP_NAME = getClass().getName()
@Field Set GENERAL_CONFIG_KEYS = []
@Field STAGE_STEP_KEYS = [
/** Runs npm scripts to run generic integration tests written on JavaScript */
'npmExecuteScripts',
/** Runs backend integration tests via the Jacoco Maven-plugin */
'mavenExecuteIntegration',
/** Publishes test results to Jenkins. It will automatically be active in cases tests are executed. */
'testsPublishResults',
]
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
/**
* The stage allows to execute project-specific integration tests.<br />
* Typically, integration tests are very project-specific, thus they can be defined here using the [stage extension mechanism](../extensibility.md).
*/
@GenerateStageDocumentation(defaultStageName = 'Integration')
void call(Map parameters = [:]) {
def script = checkScript(this, parameters) ?: this
def utils = parameters.juStabUtils ?: new Utils()
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('npmExecuteScripts', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.npmExecuteScripts)
.addIfEmpty('mavenExecuteIntegration', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.mavenExecuteIntegration)
.use()
piperStageWrapper (script: script, stageName: stageName) {
// telemetry reporting
utils.pushToSWA([step: STEP_NAME], config)
boolean publishResults = false
try {
writeTemporaryCredentials(script: script) {
if (config.npmExecuteScripts) {
publishResults = true
npmExecuteScripts script: script
}
if (config.mavenExecuteIntegration) {
publishResults = true
mavenExecuteIntegration script: script
}
}
}
finally {
if (publishResults) {
testsPublishResults script: script
}
}
}
}