mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Merge remote-tracking branch 'github/master' into docuReadDefaultFromElswhere
This commit is contained in:
commit
6a58277967
@ -209,6 +209,66 @@ steps: {}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConditionConfigKeys() {
|
||||
helper.registerAllowedMethod('libraryResource', [String.class], {s ->
|
||||
if(s == 'testDefault.yml') {
|
||||
return '''
|
||||
stages:
|
||||
testStage1:
|
||||
stepConditions:
|
||||
firstStep:
|
||||
configKeys:
|
||||
- myKey1_1
|
||||
- myKey1_2
|
||||
testStage2:
|
||||
stepConditions:
|
||||
secondStep:
|
||||
configKeys:
|
||||
- myKey2_1
|
||||
testStage3:
|
||||
stepConditions:
|
||||
thirdStep:
|
||||
configKeys:
|
||||
- myKey3_1
|
||||
'''
|
||||
} else {
|
||||
return '''
|
||||
general: {}
|
||||
steps: {}
|
||||
'''
|
||||
}
|
||||
})
|
||||
|
||||
nullScript.commonPipelineEnvironment.configuration = [
|
||||
general: [myKey1_1: 'myVal1_1'],
|
||||
stages: [:],
|
||||
steps: [thirdStep: [myKey3_1: 'myVal3_1']]
|
||||
]
|
||||
|
||||
jsr.step.piperInitRunStageConfiguration(
|
||||
script: nullScript,
|
||||
juStabUtils: utils,
|
||||
stageConfigResource: 'testDefault.yml'
|
||||
)
|
||||
|
||||
assertThat(nullScript.commonPipelineEnvironment.configuration.runStage.keySet(),
|
||||
allOf(
|
||||
containsInAnyOrder(
|
||||
'testStage1',
|
||||
'testStage3'
|
||||
),
|
||||
hasSize(2)
|
||||
)
|
||||
)
|
||||
|
||||
assertThat(nullScript.commonPipelineEnvironment.configuration.runStep.testStage1.firstStep, is(true))
|
||||
assertThat(nullScript.commonPipelineEnvironment.configuration.runStep.testStage2?.secondStep, is(false))
|
||||
assertThat(nullScript.commonPipelineEnvironment.configuration.runStep.testStage3.thirdStep, is(true))
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testConditionFilePattern() {
|
||||
helper.registerAllowedMethod('libraryResource', [String.class], {s ->
|
||||
|
@ -72,6 +72,17 @@ void call(Map parameters = [:]) {
|
||||
stepActive = true
|
||||
}
|
||||
break
|
||||
case 'configKeys':
|
||||
if (condition.getValue() instanceof List) {
|
||||
condition.getValue().each {configKey ->
|
||||
if (script.commonPipelineEnvironment.getStepConfiguration(step.getKey(), currentStage)?.get(configKey)) {
|
||||
stepActive = true
|
||||
}
|
||||
}
|
||||
} else if (script.commonPipelineEnvironment.getStepConfiguration(step.getKey(), currentStage)?.get(condition.getValue())) {
|
||||
stepActive = true
|
||||
}
|
||||
break
|
||||
case 'filePatternFromConfig':
|
||||
def conditionValue=script.commonPipelineEnvironment.getStepConfiguration(step.getKey(), currentStage)?.get(condition.getValue())
|
||||
if (conditionValue && findFiles(glob: conditionValue)) {
|
||||
|
Loading…
Reference in New Issue
Block a user