From 755ad41412c09514c199e5e9897a238e7197ab2c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 15 Mar 2021 12:59:07 +0000 Subject: [PATCH] [CI] tear down the workspace (#885) --- .ci/Jenkinsfile | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index ad5bb2abcb..cc5e6f252e 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -322,13 +322,14 @@ def generateFunctionalTestStep(Map args = [:]){ if (isPR() || isUpstreamTrigger(filter: 'PR-')) { tags += pullRequestFilter } + def workerLabels = "${platform} && immutable && docker" return { - node("${platform} && immutable && docker") { - try { - deleteDir() - unstash 'source' - withGoEnv(version: "${GO_VERSION}"){ + node("${workerLabels}") { + deleteDir() + unstash 'source' + withGoEnv(version: "${GO_VERSION}"){ + try { if(isInstalled(tool: 'docker', flag: '--version')) { dockerLogin(secret: "${DOCKER_ELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}") } @@ -339,12 +340,27 @@ def generateFunctionalTestStep(Map args = [:]){ } } } - } - } catch(e) { - error(e.toString()) - } finally { - junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/outputs/TEST-*.xml") + } finally { + junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/outputs/TEST-*.xml") archiveArtifacts allowEmptyArchive: true, artifacts: "${BASE_DIR}/outputs/TEST-*.xml" + tearDown(labels: workerLabels) + } + } + } + } +} + +/** +* Tear down the setup for the static workers. +*/ +def tearDown(Map args = [:]){ + catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') { + dir("${BASE_DIR}"){ + sh(label: 'Remove the entire module cache', script: 'go clean -modcache', returnStatus: true) + } + if (isStaticWorker(labels: args.labels)) { + dir("${WORKSPACE}") { + deleteDir() } } }