File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
pipeline-examples/external-workspace-manager Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,21 @@ node('linux') {
1313}
1414
1515// on a different node, labeled 'test', perform testing using the same workspace as previously
16+ // at the end, if the build have passed, delete the workspace
1617node(' test' ) {
1718 // compute complete workspace path, from current node to the allocated disk
1819 exws(extWorkspace) {
19- // run tests in the same workspace that the project was built
20- sh ' mvn test'
20+ try {
21+ // run tests in the same workspace that the project was built
22+ sh ' mvn test'
23+ } catch (e) {
24+ // if any exception occurs, mark the build as failed
25+ currentBuild. result = ' FAILURE'
26+ throw e
27+ } finally {
28+ // perform workspace cleanup only if the build have passed
29+ // if the build has failed, the workspace will be kept
30+ step([$class : ' WsCleanup' , cleanWhenFailure : false ])
31+ }
2132 }
2233}
You can’t perform that action at this time.
0 commit comments