You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-11-06 09:09:19 +02:00
Fix: yaml util handling for boolean with value false (#1629)
* Provide test for yamlUtils substitution with boolean value false * Fix: handle booleans with value 'false' in yaml substitution * Improve variable naming
This commit is contained in:
@@ -96,7 +96,7 @@ class YamlUtils implements Serializable {
|
||||
context.variablesReplaced = true // remember that variables were found in the YAML file that have been replaced.
|
||||
}
|
||||
|
||||
return complexResult ?: stringNode
|
||||
return (complexResult != null) ? complexResult : stringNode
|
||||
}
|
||||
else if (manifestNode instanceof List) {
|
||||
List<Object> listNode = manifestNode as List<Object>
|
||||
|
||||
@@ -445,8 +445,8 @@ public class CfManifestSubstituteVariablesTest extends BasePiperTest {
|
||||
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("services").get(0) instanceof String)
|
||||
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("booleanVariable").equals(true))
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("booleanVariable") instanceof Boolean)
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("booleanVariableTrue").equals(true))
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("booleanVariableTrue") instanceof Boolean)
|
||||
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("floatVariable") == 0.25)
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("floatVariable") instanceof Double)
|
||||
|
||||
@@ -231,8 +231,11 @@ class YamlUtilsTest extends BasePiperTest {
|
||||
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("services").get(0) instanceof String)
|
||||
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("booleanVariable").equals(true))
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("booleanVariable") instanceof Boolean)
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("booleanVariableTrue").equals(true))
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("booleanVariableTrue") instanceof Boolean)
|
||||
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("booleanVariableFalse").equals(false))
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("booleanVariableFalse") instanceof Boolean)
|
||||
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("floatVariable") == 0.25)
|
||||
assertTrue(manifestDataAfterReplacement.get("applications").get(0).get("env").get("floatVariable") instanceof Double)
|
||||
|
||||
@@ -3,7 +3,8 @@ unique-prefix: uniquePrefix # A unique prefix. E.g. your D/I/C-User
|
||||
xsuaa-instance-name: uniquePrefix-catalog-service-odatav2-xsuaa
|
||||
hana-instance-name: uniquePrefix-catalog-service-odatav2-hana
|
||||
integer-variable: 1
|
||||
boolean-variable: Yes
|
||||
boolean-variable-true: Yes
|
||||
boolean-variable-false: false
|
||||
float-variable: 0.25
|
||||
json-variable: >
|
||||
[
|
||||
|
||||
@@ -19,9 +19,10 @@ applications:
|
||||
spring.profiles.active: cloud # activate the spring profile named 'cloud'.
|
||||
xsuaa-instance-name: ((xsuaa-instance-name))
|
||||
db_service_instance_name: ((hana-instance-name))
|
||||
booleanVariable: ((boolean-variable))
|
||||
booleanVariableTrue: ((boolean-variable-true))
|
||||
booleanVariableFalse: ((boolean-variable-false))
|
||||
floatVariable: ((float-variable))
|
||||
json-variable: ((json-variable))
|
||||
object-variable: ((object-variable))
|
||||
string-variable: ((boolean-variable))-((float-variable))-((integer-variable))-((json-variable))
|
||||
single-var-with-string-constants: ((boolean-variable))-with-some-more-text
|
||||
string-variable: ((boolean-variable-true))-((float-variable))-((integer-variable))-((json-variable))
|
||||
single-var-with-string-constants: ((boolean-variable-true))-with-some-more-text
|
||||
|
||||
Reference in New Issue
Block a user