-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
65 lines (65 loc) · 2.04 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
55
56
57
58
59
60
61
62
63
64
65
pipeline {
agent any
environment {
COMMIT = "${GIT_COMMIT.substring(0,8)}"
}
stages {
stage('Build') {
steps {
sh "printenv"
echo 'Building the unit tests image.'
sh 'docker build -f Dockerfile.test . --target unit-tests -t build-slave:unit-tests'
}
}
stage('Run Tests') {
parallel {
stage('Unit tests') {
steps {
echo 'Running unit tests.'
sh "docker run \
--name ${COMMIT} \
build-slave:unit-tests"
echo 'Copying test results.'
sh "mkdir reports || echo 'folder already exists'"
sh "docker cp ${COMMIT}:/app/reports/result.xml ${pwd()}/reports/result.xml"
echo 'Remove container.'
sh "docker rm -f ${COMMIT} || true"
}
post {
always {
junit 'reports/*.xml'
}
}
}
stage('Lint tests') {
steps {
echo 'Running linting tests.'
}
}
stage('Coverage tests') {
steps {
echo 'Running coverage tests.'
}
}
}
}
stage('Staging') {
when { not { tag '*'} }
steps {
echo 'Deploying to staging.'
}
}
stage('Production') {
when { tag 'release-*'}
steps {
echo 'Deploying to production.'
}
}
stage('Teardown') {
steps {
echo 'Cleaning up artifacts.'
sh 'rm -rf /reports'
}
}
}
}