This is an automated email from the ASF dual-hosted git repository.

rec pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/uima-build-jenkins-shared-library.git


The following commit(s) were added to refs/heads/main by this push:
     new 9c1317e  [UIMA-6457] Clean Jenkins workspace up after build
9c1317e is described below

commit 9c1317e1d9b05bdaaa26092437607dc2bccfff4b
Author: Richard Eckart de Castilho <[email protected]>
AuthorDate: Fri Jun 3 14:55:04 2022 +0200

    [UIMA-6457] Clean Jenkins workspace up after build
    
    - Also add option to clean before build
---
 vars/createConfiguration.groovy |  1 +
 vars/defaultPipeline.groovy     | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/vars/createConfiguration.groovy b/vars/createConfiguration.groovy
index df61453..4df7c50 100644
--- a/vars/createConfiguration.groovy
+++ b/vars/createConfiguration.groovy
@@ -23,6 +23,7 @@ def call(body) {
     maven: 'maven_latest',
     jdk: 'jdk_17_latest',
     extraMavenArguments: '',
+    wipeWorkspaceBeforeBuild: true,
     wipeWorkspaceAfterBuild: true
   ]
   
diff --git a/vars/defaultPipeline.groovy b/vars/defaultPipeline.groovy
index c33f2dd..10a584a 100644
--- a/vars/defaultPipeline.groovy
+++ b/vars/defaultPipeline.groovy
@@ -32,6 +32,10 @@ def call(body) {
         name: 'agentLabel',
         defaultValue: config.agentLabel,
         description: "Eligible agents (in case a build keeps running on a 
broken agent; overrides only current build)")
+      booleanParam(
+        name: 'wipeWorkspaceBeforeBuild',
+        defaultValue: config.wipeWorkspaceBeforeBuild,
+        description: "Wipe workspace before build (for testing; next build 
only)")
       booleanParam(
         name: 'wipeWorkspaceAfterBuild',
         defaultValue: config.wipeWorkspaceAfterBuild,
@@ -74,6 +78,16 @@ def call(body) {
           stages {
             stage("Checkout code") {
               steps {
+                script {
+                  if (params.wipeWorkspaceBeforeBuild) {
+                    echo "Wiping workspace..."
+                    cleanWs(cleanWhenNotBuilt: true,
+                            deleteDirs: true,
+                            disableDeferredWipeout: true,
+                            notFailBuild: true)
+                  }
+                }
+  
                 dir('checkout') {
                   checkout scm
                 }

Reply via email to