1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-18 05:18:24 +02:00

correct handling of parameter maps

This commit is contained in:
Christopher Fenner 2018-02-08 10:50:11 +01:00
parent 4abbff8b70
commit c6300f4570
2 changed files with 30 additions and 14 deletions

View File

@ -122,13 +122,29 @@ class ChecksPublishResultsTest extends BasePipelineTest {
assertTrue("AnalysisPublisher options not set", publisherStepOptions['AnalysisPublisher'] != null)
// ensure nothing else is published
assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] == null)
assertTrue("PmdPublisher options not empty", publisherStepOptions['PmdPublisher'] == null)
assertTrue("DryPublisher options not empty", publisherStepOptions['DryPublisher'] == null)
assertTrue("FindBugsPublisher options not empty", publisherStepOptions['FindBugsPublisher'] == null)
assertTrue("CheckStylePublisher options not empty", publisherStepOptions['CheckStylePublisher'] == null)
assertTrue("WarningsPublisher options not empty", publisherStepOptions['WarningsPublisher'] == null)
}
@Test
void testPublishNothingImplicitTrue() throws Exception {
stepUnderTest.call(pmd: [:])
// ensure pmd is not published
assertTrue("PmdPublisher options not set", publisherStepOptions['PmdPublisher'] != null)
}
@Test
void testPublishNothingExplicitActiveFalse() throws Exception {
stepUnderTest.call(pmd: [active: false])
// ensure pmd is not published
assertTrue("PmdPublisher options not empty", publisherStepOptions['PmdPublisher'] == null)
}
@Test
void testPublishWithChangedStepDefaultSettings() throws Exception {
// pmd has been set to active: true in step configuration

View File

@ -94,19 +94,6 @@ def reportWarnings(parserName, settings, doArchive){
}
}
@NonCPS
def toMap(parameter){
if(MapUtils.isMap(parameter))
parameter.put('active', true)
else if(Boolean.TRUE.equals(parameter))
parameter = [active: true]
else if(Boolean.FALSE.equals(parameter))
parameter = [active: false]
else
parameter = [:]
return parameter
}
def archiveResults(archive, pattern, allowEmpty){
if(archive){
echo "[${STEP_NAME}] archive ${pattern}"
@ -153,3 +140,16 @@ def prepare(parameters){
parameters.pylint = toMap(parameters.pylint)
return parameters
}
@NonCPS
def toMap(parameter){
if(MapUtils.isMap(parameter))
parameter.put('active', parameter.active == null?true:parameter.active)
else if(Boolean.TRUE.equals(parameter))
parameter = [active: true]
else if(Boolean.FALSE.equals(parameter))
parameter = [active: false]
else
parameter = [:]
return parameter
}