mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
fix(kubernetes): invalidate stashes after usage (#1064)
* fix(kubernetes): invalidate stashes after usage fixes #1057 * adjust test case
This commit is contained in:
parent
68ef5393c7
commit
57ae0e8f8d
@ -465,7 +465,7 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void tastStashIncludesAndExcludes() {
|
||||
void testStashIncludesAndExcludes() {
|
||||
nullScript.commonPipelineEnvironment.configuration = [
|
||||
steps: [
|
||||
dockerExecuteOnKubernetes: [
|
||||
@ -487,8 +487,14 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest {
|
||||
) {
|
||||
bodyExecuted = true
|
||||
}
|
||||
assertThat(stashList[0], allOf(hasEntry('includes','workspace/include.test'), hasEntry('excludes','workspace/exclude.test')))
|
||||
assertThat(stashList[1], allOf(hasEntry('includes','container/include.test'), hasEntry('excludes','container/exclude.test')))
|
||||
assertThat(stashList, hasItem(allOf(
|
||||
not(hasEntry('allowEmpty', true)),
|
||||
hasEntry('includes','workspace/include.test'),
|
||||
hasEntry('excludes','workspace/exclude.test'))))
|
||||
assertThat(stashList, hasItem(allOf(
|
||||
not(hasEntry('allowEmpty', true)),
|
||||
hasEntry('includes','container/include.test'),
|
||||
hasEntry('excludes','container/exclude.test'))))
|
||||
}
|
||||
|
||||
|
||||
|
@ -249,6 +249,8 @@ void executeOnPod(Map config, utils, Closure body, Script script) {
|
||||
container(containerParams) {
|
||||
try {
|
||||
utils.unstashAll(stashContent)
|
||||
echo "invalidate stash workspace-${config.uniqueId}"
|
||||
stash name: "workspace-${config.uniqueId}", excludes: '**/*', allowEmpty: true
|
||||
body()
|
||||
} finally {
|
||||
stashWorkspace(config, 'container', true, true)
|
||||
@ -325,6 +327,8 @@ private Map getSecurityContext(Map config) {
|
||||
private void unstashWorkspace(config, prefix) {
|
||||
try {
|
||||
unstash "${prefix}-${config.uniqueId}"
|
||||
echo "invalidate stash ${prefix}-${config.uniqueId}"
|
||||
stash name: "${prefix}-${config.uniqueId}", excludes: '**/*', allowEmpty: true
|
||||
} catch (AbortException | IOException e) {
|
||||
echo "${e.getMessage()}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user