1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-09-16 09:26:22 +02:00

feat (remove key from commonPipelineEnvironment) (#4074)

* Add method to remove values from commonPipelineEnvironment

* Add test to validate remove value from map

Co-authored-by: i850487 <thilaknath.ashok.kumar@sap.com>
This commit is contained in:
Thilaknath
2022-11-03 10:27:47 -04:00
committed by GitHub
parent 761dc75e82
commit e25b2a126f
2 changed files with 12 additions and 0 deletions

View File

@@ -51,6 +51,14 @@ class CommonPipelineEnvironmentTest extends BasePiperTest {
assertThat(nullScript.commonPipelineEnvironment.getValue('myList').key2, is('val2'))
}
@Test
void testKeyRemoveFromMap() {
nullScript.commonPipelineEnvironment.setValue('myList', [])
nullScript.commonPipelineEnvironment.getValue('myList').add('item1')
nullScript.commonPipelineEnvironment.removeValue('myList')
assertThat(nullScript.commonPipelineEnvironment.getValue('myList'), is(null))
}
@Test
void testContainereMap() {
nullScript.commonPipelineEnvironment.setContainerProperty('image', 'myImage')

View File

@@ -66,6 +66,10 @@ class commonPipelineEnvironment implements Serializable {
valueMap[property] = value
}
void removeValue(String property) {
valueMap.remove(property)
}
def getValue(String property) {
return valueMap.get(property)
}