github.com/jaylevin/jenkins-library@v1.230.4/vars/piperPipelineStagePost.groovy (about) 1 import com.sap.piper.ConfigurationHelper 2 import com.sap.piper.GenerateDocumentation 3 import com.sap.piper.StageNameProvider 4 import com.sap.piper.Utils 5 import groovy.transform.Field 6 7 import static com.sap.piper.Prerequisites.checkScript 8 9 @Field String STEP_NAME = getClass().getName() 10 @Field String TECHNICAL_STAGE_NAME = 'postPipelineHook' 11 @Field Set GENERAL_CONFIG_KEYS = ["vaultServerUrl", "vaultAppRoleTokenCredentialsId", "vaultAppRoleSecretTokenCredentialsId"] 12 @Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(["vaultRotateSecretId"]) 13 @Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS 14 15 /** 16 * In this stage reporting actions like mail notification or telemetry reporting are executed. 17 * 18 * This stage contains following steps: 19 * - [vaultRotateSecretId](./vaultRotateSecretId.md) 20 * - [influxWriteData](./influxWriteData.md) 21 * - [mailSendNotification](./mailSendNotification.md) 22 * 23 * !!! note 24 * This stage is meant to be used in a [post](https://jenkins.io/doc/book/pipeline/syntax/#post) section of a pipeline. 25 */ 26 @GenerateDocumentation 27 void call(Map parameters = [:]) { 28 def script = checkScript(this, parameters) ?: this 29 def utils = parameters.juStabUtils ?: new Utils() 30 def stageName = StageNameProvider.instance.getStageName(script, parameters, this) 31 // ease handling extension 32 stageName = stageName.replace('Declarative: ', '') 33 34 Map config = ConfigurationHelper.newInstance(this) 35 .loadStepDefaults([:], stageName) 36 .mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS) 37 .mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS) 38 .mixin(parameters, PARAMETER_KEYS) 39 .addIfEmpty("vaultRotateSecretId", false) 40 .use() 41 42 piperStageWrapper (script: script, stageName: stageName, stageLocking: false) { 43 // rotate vault secret id if necessary 44 if (config.vaultRotateSecretId && config.vaultServerUrl && config.vaultAppRoleSecretTokenCredentialsId 45 && config.vaultAppRoleTokenCredentialsId) { 46 vaultRotateSecretId script: script 47 } 48 49 // telemetry reporting 50 utils.pushToSWA([step: STEP_NAME], config) 51 52 influxWriteData script: script 53 if(env.BRANCH_NAME == parameters.script.commonPipelineEnvironment.getStepConfiguration('', '').productiveBranch) { 54 if(parameters.script.commonPipelineEnvironment.configuration.runStep?.get('Post Actions')?.slackSendNotification) { 55 slackSendNotification script: parameters.script 56 } 57 } 58 59 mailSendNotification script: script 60 debugReportArchive script: script 61 piperPublishWarnings script: script 62 } 63 }