From 15d078efa4ebc17f163578ce139fa163e72f7fc2 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 15 Mar 2021 09:48:12 +0000 Subject: [PATCH 1/3] [CI] tear down the workspace --- .ci/Jenkinsfile | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 97c3998e75..5ed641f30e 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -322,9 +322,10 @@ def generateFunctionalTestStep(Map args = [:]){ if (isPR() || isUpstreamTrigger(filter: 'PR-')) { tags += pullRequestFilter } + def workerLabels = "${platform} && immutable && docker" return { - node("${platform} && immutable && docker") { + node("${workerLabels}") { try { deleteDir() unstash 'source' @@ -344,7 +345,24 @@ def generateFunctionalTestStep(Map args = [:]){ error(e.toString()) } finally { junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/outputs/TEST-*.xml") - archiveArtifacts allowEmptyArchive: true, artifacts: "${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.workerLabels)) { + dir("${WORKSPACE}") { + deleteDir() } } } From 53245f16ea258d054cc96e7b3a5b57b7d0ad8831 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 15 Mar 2021 09:51:20 +0000 Subject: [PATCH 2/3] Update .ci/Jenkinsfile --- .ci/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 5ed641f30e..3e4906df8e 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -360,7 +360,7 @@ def tearDown(Map args = [:]){ dir("${BASE_DIR}"){ sh(label: 'Remove the entire module cache', script: 'go clean -modcache', returnStatus: true) } - if (isStaticWorker(labels: args.workerLabels)) { + if (isStaticWorker(labels: args.labels)) { dir("${WORKSPACE}") { deleteDir() } From 4630b71dfe412fd410ab60e18c3ac0ab65e1f28d Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 15 Mar 2021 10:58:10 +0000 Subject: [PATCH 3/3] withGoEnv closure for the try/finally --- .ci/Jenkinsfile | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 3e4906df8e..a078f172e5 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -326,10 +326,10 @@ def generateFunctionalTestStep(Map args = [:]){ return { node("${workerLabels}") { - try { - deleteDir() - unstash 'source' - withGoEnv(version: "${GO_VERSION}"){ + deleteDir() + unstash 'source' + withGoEnv(version: "${GO_VERSION}"){ + try { if(isInstalled(tool: 'docker', flag: '--version')) { dockerLogin(secret: "${DOCKER_ELASTIC_SECRET}", registry: "${DOCKER_REGISTRY}") } @@ -340,13 +340,11 @@ def generateFunctionalTestStep(Map args = [:]){ } } } + } finally { + junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/outputs/TEST-*.xml") + archiveArtifacts allowEmptyArchive: true, artifacts: "${BASE_DIR}/outputs/TEST-*.xml" + tearDown(labels: workerLabels) } - } catch(e) { - error(e.toString()) - } finally { - junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/outputs/TEST-*.xml") - archiveArtifacts allowEmptyArchive: true, artifacts: "${BASE_DIR}/outputs/TEST-*.xml" - tearDown(labels: workerLabels) } } }