github.com/xgoffin/jenkins-library@v1.154.0/vars/abapEnvironmentPipelineStagePost.groovy (about)

     1  import groovy.transform.Field
     2  import com.sap.piper.ConfigurationHelper
     3  
     4  import static com.sap.piper.Prerequisites.checkScript
     5  
     6  @Field String STEP_NAME = getClass().getName()
     7  @Field Set GENERAL_CONFIG_KEYS = [
     8      /** If set to true, the system is never deleted */
     9      'debug'
    10  ]
    11  @Field STAGE_STEP_KEYS = [
    12      /** Deletes a SAP Cloud Platform ABAP Environment instance via the cloud foundry command line interface */
    13      'cloudFoundryDeleteService',
    14      /** If set to true, a confirmation is required to delete the system in case the pipeline was not successful */
    15      'confirmDeletion'
    16  ]
    17  @Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS)
    18  @Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
    19  /**
    20   * This stage cleans up the ABAP Environment Pipeline run
    21   */
    22  void call(Map parameters = [:]) {
    23      def script = checkScript(this, parameters) ?: this
    24      def stageName = parameters.stageName?:env.STAGE_NAME
    25      stageName = stageName.replace('Declarative: ', '')
    26      stageName = stageName.replace(' Actions', '')
    27  
    28      Map config = ConfigurationHelper.newInstance(this)
    29          .loadStepDefaults()
    30          .mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
    31          .mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS)
    32          .mixin(parameters, PARAMETER_KEYS)
    33          .addIfEmpty('confirmDeletion', false)
    34          .addIfEmpty('debug', false)
    35          .use()
    36  
    37      piperStageWrapper (script: script, stageName: stageName, stashContent: [], stageLocking: false) {
    38          if(parameters.script.commonPipelineEnvironment.configuration.runStage?.get("Prepare System")) {
    39  
    40              if (config.confirmDeletion && script.currentBuild.result != 'SUCCESS') {
    41                  input message: "Pipeline status is not successful. Once you proceed, the system will be deleted."
    42              }
    43              if (!config.debug) {
    44                  cloudFoundryDeleteService script: parameters.script
    45              }
    46          }
    47      }
    48  }