CI: cleanup workspace after successfull build
authorJan Vrany <jan.vrany@labware.com>
Tue, 23 Jun 2020 12:21:39 +0100
changeset 295 a04034567c92
parent 294 0f3980335d2b
child 300 ad960fb1bba1
CI: cleanup workspace after successfull build ...to save disk space.
ci/build.groovy
ci/integrate.groovy
ci/steps.groovy
--- a/ci/build.groovy	Tue Jun 23 12:16:02 2020 +0100
+++ b/ci/build.groovy	Tue Jun 23 12:21:39 2020 +0100
@@ -53,3 +53,4 @@
  * ...and fire the pipeline
  */
 steps.build()
+steps.cleanup()
\ No newline at end of file
--- a/ci/integrate.groovy	Tue Jun 23 12:16:02 2020 +0100
+++ b/ci/integrate.groovy	Tue Jun 23 12:21:39 2020 +0100
@@ -50,6 +50,7 @@
 steps.branch = branch()
 
 /*
- * ...and fire the pipeline 
+ * ...and fire the pipeline
  */
 steps.integration()
+steps.cleanup()
\ No newline at end of file
--- a/ci/steps.groovy	Tue Jun 23 12:16:02 2020 +0100
+++ b/ci/steps.groovy	Tue Jun 23 12:21:39 2020 +0100
@@ -282,6 +282,17 @@
     }
 }
 
+/**
+ * Cleanup the workspace
+ */
+ def cleanup() {
+    matrix ( configurations ) {
+        stage ( "Cleanup - {${env.BUILD_TARGET}}") {
+            cleanWs cleanWhenAborted: false, cleanWhenFailure: false, cleanWhenNotBuilt: false, cleanWhenUnstable: false
+        }
+    }
+ }
+
 /*
  * Utility. Executes given block with credentials for upstream repository.
  */