Skip to content

Commit

Permalink
Add configuration support for postActions (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-kurzynski authored and fwilhe committed May 7, 2018
1 parent 286a1f0 commit e8fb41a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/com/sap/piper/ConfigurationLoader.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class ConfigurationLoader implements Serializable {
return DefaultValueCache.getInstance()?.getDefaultValues()?.general ?: [:]
}

@NonCPS
static Map postActionConfiguration(script, String actionName){
return loadConfiguration(script, 'postActions', actionName, ConfigurationType.CUSTOM_CONFIGURATION)
}

@NonCPS
private static Map loadConfiguration(script, String type, String entryName, ConfigurationType configType){
switch (configType) {
Expand Down
7 changes: 7 additions & 0 deletions test/groovy/com/sap/piper/ConfigurationLoaderTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ConfigurationLoaderTest {
configuration.general = [productiveBranch: 'master']
configuration.steps = [executeMaven: [dockerImage: 'maven:3.2-jdk-8-onbuild']]
configuration.stages = [staticCodeChecks: [pmdExcludes: '**']]
configuration.postActions = [sendEmail: [recipients: 'myEmail']]

Map defaultConfiguration = [:]
defaultConfiguration.general = [productiveBranch: 'develop']
Expand Down Expand Up @@ -56,4 +57,10 @@ class ConfigurationLoaderTest {
Map config = ConfigurationLoader.defaultGeneralConfiguration(getScript())
Assert.assertEquals('develop', config.productiveBranch)
}

@Test
void testLoadPostActionConfiguration(){
Map config = ConfigurationLoader.postActionConfiguration(getScript(), 'sendEmail')
Assert.assertEquals('myEmail', config.recipients)
}
}

0 comments on commit e8fb41a

Please sign in to comment.