1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

piperPipeline: add extensible post stage (#661)

* add post stage

* use post stage in template

* adjust test cases

* add docs skeleton

* add documentation

* Update piperPipelineStagePost.md
This commit is contained in:
Christopher Fenner 2019-05-02 12:26:28 +02:00 committed by GitHub
parent 99821afab8
commit e8f206b1a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 3 deletions

View File

@ -0,0 +1,7 @@
# ${docGenStepName}
## ${docGenDescription}
## ${docGenParameters}
## ${docGenConfiguration}

View File

@ -160,6 +160,9 @@ class PiperPipelineTest extends BasePiperTest {
helper.registerAllowedMethod('piperPipelineStageRelease', [Map.class], {m ->
stepsCalled.add('piperPipelineStageRelease')
})
helper.registerAllowedMethod('piperPipelineStagePost', [Map.class], {m ->
stepsCalled.add('piperPipelineStagePost')
})
nullScript.prepareDefaultValues(script: nullScript)
@ -231,7 +234,8 @@ class PiperPipelineTest extends BasePiperTest {
'piperPipelineStageCompliance',
'input',
'piperPipelineStagePromote',
'piperPipelineStageRelease'
'piperPipelineStageRelease',
'piperPipelineStagePost'
))
}
}

View File

@ -87,8 +87,7 @@ void call(parameters) {
failure {buildSetResult(currentBuild, 'FAILURE')}
unstable {buildSetResult(currentBuild, 'UNSTABLE')}
cleanup {
influxWriteData script: parameters.script, wrapInNode: true
mailSendNotification script: parameters.script, wrapInNode: true
piperPipelineStagePost script: parameters.script
}
}
}

View File

@ -0,0 +1,45 @@
import com.sap.piper.ConfigurationHelper
import com.sap.piper.GenerateDocumentation
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 Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS
@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:
* - [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()
def stageName = parameters.stageName?:env.STAGE_NAME
// ease handling extension
stageName = stageName.replace('Declarative: ', '')
Map config = ConfigurationHelper.newInstance(this)
.loadStepDefaults()
.mixinGeneralConfig(script.commonPipelineEnvironment, GENERAL_CONFIG_KEYS)
.mixinStageConfig(script.commonPipelineEnvironment, stageName, STEP_CONFIG_KEYS)
.mixin(parameters, PARAMETER_KEYS)
.use()
piperStageWrapper (script: script, stageName: stageName, stageLocking: false) {
// telemetry reporting
utils.pushToSWA([step: STEP_NAME], config)
influxWriteData script: script
mailSendNotification script: script
}
}