From f10a8c62466b56e2df285c34d9e8dd9aad64b26d Mon Sep 17 00:00:00 2001 From: Christopher Fenner Date: Fri, 5 Oct 2018 10:51:01 +0200 Subject: [PATCH] dockerExecuteOnKubernetes: fix stash overriding (#329) * dockerExecuteOnKubernetes: fix stash overriding * update comment --- vars/dockerExecuteOnKubernetes.groovy | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/vars/dockerExecuteOnKubernetes.groovy b/vars/dockerExecuteOnKubernetes.groovy index c2ee5bb3b..65f475029 100644 --- a/vars/dockerExecuteOnKubernetes.groovy +++ b/vars/dockerExecuteOnKubernetes.groovy @@ -84,9 +84,9 @@ void executeOnPodWithSingleContainer(Map parameters, body) { - The container method - The body * We use nested exception handling in this case. - * In the first 2 cases, the workspace has not been modified. Hence, we can stash existing workspace as container and - * unstash in the finally block. In case of exception thrown by the body, we need to stash the workspace from the container - * in finally block + * In the first 2 cases, the 'container' stash is not created because the inner try/finally is not reached. + * However, the workspace has not been modified and don't need to be restored. + * In case third case, we need to create the 'container' stash to bring the modified content back to the host. */ try { stashWorkspace(config, 'workspace') @@ -98,13 +98,10 @@ void executeOnPodWithSingleContainer(Map parameters, body) { body() } finally { stashWorkspace(config, 'container') - } + } } } } - } catch (e) { - stashWorkspace(config, 'container') - throw e } finally { unstashWorkspace(config, 'container') }