2019-05-02 12:26:28 +02:00
|
|
|
import com.sap.piper.ConfigurationHelper
|
|
|
|
import com.sap.piper.GenerateDocumentation
|
2020-08-28 16:11:35 +02:00
|
|
|
import com.sap.piper.StageNameProvider
|
2019-05-02 12:26:28 +02:00
|
|
|
import com.sap.piper.Utils
|
|
|
|
import groovy.transform.Field
|
|
|
|
|
|
|
|
import static com.sap.piper.Prerequisites.checkScript
|
|
|
|
|
|
|
|
@Field String STEP_NAME = getClass().getName()
|
2020-08-28 16:11:35 +02:00
|
|
|
@Field String TECHNICAL_STAGE_NAME = 'postPipelineHook'
|
2020-11-17 14:49:31 +02:00
|
|
|
@Field Set GENERAL_CONFIG_KEYS = ["vaultServerUrl", "vaultAppRoleTokenCredentialsId", "vaultAppRoleSecretTokenCredentialsId"]
|
|
|
|
@Field STAGE_STEP_KEYS = ["vaultRotateSecretId"]
|
2019-07-03 10:13:26 +02:00
|
|
|
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
|
2019-05-02 12:26:28 +02:00
|
|
|
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
|
|
|
|
|
|
|
|
/**
|
|
|
|
* In this stage reporting actions like mail notification or telemetry reporting are executed.
|
|
|
|
*
|
|
|
|
* This stage contains following steps:
|
2020-11-17 14:49:31 +02:00
|
|
|
* - [vaultRotateSecretId](./vaultRotateSecretId.md)
|
2019-05-02 12:26:28 +02:00
|
|
|
* - [influxWriteData](./influxWriteData.md)
|
|
|
|
* - [mailSendNotification](./mailSendNotification.md)
|
|
|
|
*
|
|
|
|
* !!! note
|
|
|
|
* This stage is meant to be used in a [post](https://jenkins.io/doc/book/pipeline/syntax/#post) section of a pipeline.
|
|
|
|
*/
|
|
|
|
@GenerateDocumentation
|
|
|
|
void call(Map parameters = [:]) {
|
|
|
|
def script = checkScript(this, parameters) ?: this
|
|
|
|
def utils = parameters.juStabUtils ?: new Utils()
|
2020-08-28 16:11:35 +02:00
|
|
|
def stageName = StageNameProvider.instance.getStageName(script, parameters, this)
|
2019-05-02 12:26:28 +02:00
|
|
|
// ease handling extension
|
|
|
|
stageName = stageName.replace('Declarative: ', '')
|
2020-08-28 16:11:35 +02:00
|
|
|
|
2019-05-02 12:26:28 +02:00
|
|
|
Map config = ConfigurationHelper.newInstance(this)
|
|
|
|
.loadStepDefaults()
|
|
|
|
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
|
|
|
|
.mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS)
|
|
|
|
.mixin(parameters, PARAMETER_KEYS)
|
2020-11-17 14:49:31 +02:00
|
|
|
.addIfEmpty("vaultRotateSecretId", false)
|
2019-05-02 12:26:28 +02:00
|
|
|
.use()
|
|
|
|
|
|
|
|
piperStageWrapper (script: script, stageName: stageName, stageLocking: false) {
|
2020-11-17 14:49:31 +02:00
|
|
|
// rotate vault secret id if necessary
|
|
|
|
if (config.vaultRotateSecretId && config.vaultServerUrl && config.vaultAppRoleSecretTokenCredentialsId
|
|
|
|
&& config.vaultAppRoleTokenCredentialsId) {
|
|
|
|
vaultRotateSecretId script: script
|
|
|
|
}
|
|
|
|
|
2019-05-02 12:26:28 +02:00
|
|
|
// telemetry reporting
|
|
|
|
utils.pushToSWA([step: STEP_NAME], config)
|
|
|
|
|
|
|
|
influxWriteData script: script
|
2019-05-10 06:47:44 +02:00
|
|
|
if(env.BRANCH_NAME == parameters.script.commonPipelineEnvironment.getStepConfiguration('', '').productiveBranch) {
|
|
|
|
if(parameters.script.commonPipelineEnvironment.configuration.runStep?.get('Post Actions')?.slackSendNotification) {
|
|
|
|
slackSendNotification script: parameters.script
|
|
|
|
}
|
|
|
|
}
|
2020-10-01 10:14:14 +02:00
|
|
|
|
2019-05-02 12:26:28 +02:00
|
|
|
mailSendNotification script: script
|
2020-10-01 10:14:14 +02:00
|
|
|
debugReportArchive script: script
|
2019-07-18 12:09:54 +02:00
|
|
|
piperPublishWarnings script: script
|
2019-05-02 12:26:28 +02:00
|
|
|
}
|
|
|
|
}
|