forked from cyverse-archive/de-ui-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
54 lines (43 loc) · 1.7 KB
/
Jenkinsfile
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!groovy
milestone 0
def repo = "ui-lib"
timestamps {
node('docker') {
slackJobDescription = "job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})"
dockerCacheVolumes = """-v /tmp:/tmp -v "\$(pwd)/node_modules:/src/ui-lib/node_modules\""""
try {
dir('git-checkout') {
stage "Prepare"
checkout scm
stage "Create Test Image"
milestone 20
dockerRepoTest = "test-${repo}-${env.BUILD_TAG}"
dockerTestRunner = "test-${repo}-${env.BUILD_TAG}"
sh "docker build --pull --rm -t ${dockerRepoTest} ."
}
try {
stage "Test"
milestone 30
sh "docker run ${dockerCacheVolumes} --rm ${dockerRepoTest} npm install"
milestone 40
sh "docker run ${dockerCacheVolumes} --name ${dockerTestRunner} ${dockerRepoTest}"
sh "docker cp ${dockerTestRunner}:/src/ui-lib/test-report.xml ./test-report.xml"
junit "test-report.xml"
milestone 50
} finally {
sh returnStatus: true, script: "docker kill ${dockerTestRunner}"
sh returnStatus: true, script: "docker rm ${dockerTestRunner}"
sh returnStatus: true, script: "docker rmi ${dockerRepoTest}"
}
} catch (InterruptedException e) {
currentBuild.result = "ABORTED"
slackSend color: 'warning', message: "ABORTED: ${slackJobDescription}"
throw e
} catch (e) {
currentBuild.result = "FAILED"
sh "echo ${e}"
slackSend color: 'danger', message: "FAILED: ${slackJobDescription}"
throw e
}
}
}