2019-02-05 16:37:59 +02:00
|
|
|
import com.sap.piper.ConfigurationHelper
|
2019-07-05 16:32:24 +02:00
|
|
|
import com.sap.piper.GenerateStageDocumentation
|
2019-02-05 16:37:59 +02:00
|
|
|
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 = []
|
2020-06-17 18:17:05 +02:00
|
|
|
@Field STAGE_STEP_KEYS = [
|
|
|
|
/** Runs npm scripts to run generic integration tests written on JavaScript */
|
|
|
|
'npmExecuteScripts',
|
|
|
|
/** Publishes test results to Jenkins. It will automatically be active in cases tests are executed. */
|
|
|
|
'testsPublishResults',
|
|
|
|
]
|
2019-07-03 10:13:26 +02:00
|
|
|
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
|
2019-02-05 16:37:59 +02:00
|
|
|
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
|
|
|
|
2019-07-03 10:13:26 +02:00
|
|
|
/**
|
|
|
|
* 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).
|
|
|
|
*/
|
2019-07-05 16:32:24 +02:00
|
|
|
@GenerateStageDocumentation(defaultStageName = 'Integration')
|
2019-02-05 16:37:59 +02:00
|
|
|
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)
|
2020-06-17 18:17:05 +02:00
|
|
|
.addIfEmpty('npmExecuteScripts', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.npmExecuteScripts)
|
2019-02-05 16:37:59 +02:00
|
|
|
.use()
|
|
|
|
|
|
|
|
piperStageWrapper (script: script, stageName: stageName) {
|
|
|
|
|
|
|
|
// telemetry reporting
|
|
|
|
utils.pushToSWA([step: STEP_NAME], config)
|
|
|
|
|
2020-06-17 18:17:05 +02:00
|
|
|
boolean publishResults = false
|
|
|
|
try {
|
|
|
|
if (config.npmExecuteScripts) {
|
|
|
|
publishResults = true
|
|
|
|
//TODO Remove once config resolution supports technical names as well as labels for stages
|
|
|
|
withEnv(["STAGE_NAME=${stageName}"]) {
|
|
|
|
npmExecuteScripts script: script
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally {
|
|
|
|
if (publishResults) {
|
|
|
|
testsPublishResults script: script
|
|
|
|
}
|
|
|
|
}
|
2019-02-05 16:37:59 +02:00
|
|
|
}
|
|
|
|
}
|