-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexternalWorkspaceManager.groovy
More file actions
33 lines (31 loc) · 1.21 KB
/
externalWorkspaceManager.groovy
File metadata and controls
33 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// allocate a Disk from the Disk Pool defined in the Jenkins global config
def extWorkspace = exwsAllocate 'diskpool1'
// on a node labeled 'linux', perform code checkout and build the project
node('linux') {
// compute complete workspace path, from current node to the allocated disk
exws(extWorkspace) {
// checkout code from repo
checkout scm
// build project, but skip running tests
sh 'mvn clean install -DskipTests'
}
}
// on a different node, labeled 'test', perform testing using the same workspace as previously
// at the end, if the build have passed, delete the workspace
node('test') {
// compute complete workspace path, from current node to the allocated disk
exws(extWorkspace) {
try {
// run tests in the same workspace that the project was built
sh 'mvn test'
} catch (e) {
// if any exception occurs, mark the build as failed
currentBuild.result = 'FAILURE'
throw e
} finally {
// perform workspace cleanup only if the build have passed
// if the build has failed, the workspace will be kept
cleanWs cleanWhenFailure: false
}
}
}