-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
97 lines (93 loc) · 2.9 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
pipeline {
agent any
options {
skipDefaultCheckout()
skipStagesAfterUnstable()
}
stages {
stage('Checkout') {
steps {
cleanWs()
echo 'Checkout..'
checkout scm
}
}
stage('Build') {
steps {
echo 'Building..'
sh """
python3 -m venv env
chmod 754 env/bin/activate
. env/bin/activate
python3 -m pip install -r requirements.txt
"""
}
}
stage('Run unit tests') {
steps {
echo 'Running unit tests..'
sh """
. env/bin/activate
pytest app/test/unittest/ --cache-clear -rxs -v --junitxml=unit_test_report.xml
"""
}
post {
always {
junit allowEmptyResults: true, testResults: 'unit_test_report.xml'
}
}
}
stage('Run integration tests') {
steps {
echo 'Running integration tests..'
sh """
. env/bin/activate
pytest app/test/integrationtest/ --cache-clear -rxs -v --junitxml=integration_test_report.xml
"""
}
post {
always {
junit allowEmptyResults: true, testResults: 'integration_test_report.xml'
}
}
}
stage('Send to static code analyser') {
steps {
echo 'Sending test data to static code analyser..'
sh """
. env/bin/activate
pytest app/test/ --cache-clear -rxs -v --cov=. --cov-report=xml --cov-config=.coveragerc
"""
}
post {
always {
withCredentials([string(credentialsId: 'codacy-project-token', variable: 'CODACY_PROJECT_TOKEN')]) {
sh """
. env/bin/activate
export CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN
python-codacy-coverage -r coverage.xml
"""
}
}
}
}
stage('Deploy to development') {
when {
branch 'dev'
}
steps {
echo 'Deploying to development instance..'
sh "git push -f [email protected]:iot-restful-webservice-dev.git HEAD:master"
}
}
stage('Deploy to production') {
when {
branch 'master'
}
steps {
echo 'Deploying to production instance..'
sh "git push -f [email protected]:iot-restful-webservice-prod.git HEAD:master"
}
}
}
}