mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-18 05:18:24 +02:00
Merge pull request #512 from marcusholl/pr/unstashSkipNull
Unstash in loop only if identifier is available
This commit is contained in:
commit
466cee5e1d
@ -55,6 +55,7 @@ def stashWithMessage(name, msg, include = '**/*.*', exclude = '') {
|
||||
}
|
||||
|
||||
def unstash(name, msg = "Unstash failed:") {
|
||||
|
||||
def unstashedContent = []
|
||||
try {
|
||||
echo "Unstash content: ${name}"
|
||||
@ -70,7 +71,9 @@ def unstashAll(stashContent) {
|
||||
def unstashedContent = []
|
||||
if (stashContent) {
|
||||
for (i = 0; i < stashContent.size(); i++) {
|
||||
unstashedContent += unstash(stashContent[i])
|
||||
if(stashContent[i]) {
|
||||
unstashedContent += unstash(stashContent[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
return unstashedContent
|
||||
|
@ -38,6 +38,7 @@ class UtilsTest extends BasePiperTest {
|
||||
void setup() {
|
||||
|
||||
parameters = [:]
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -70,4 +71,11 @@ class UtilsTest extends BasePiperTest {
|
||||
// generated with "echo -n 'ContinuousDelivery' | sha1sum | sed 's/ -//'"
|
||||
assertThat(result, is('0dad6c33b6246702132454f604dee80740f399ad'))
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnstashAllSkipNull() {
|
||||
|
||||
def stashResult = utils.unstashAll(['a', null, 'b'])
|
||||
assert stashResult == ['a', 'b']
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user