-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathJenkinsfile
107 lines (93 loc) · 2.98 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
98
99
100
101
102
103
104
105
106
107
#!groovy
pipeline {
agent {
docker {
image 'python:3.7'
}
}
stages {
stage('Environment preparation') {
steps {
echo "-=- preparing project environment -=-"
// Python dependencies
sh "pip install -r requirements.txt"
}
}
stage('Compile') {
steps {
echo "-=- compiling project -=-"
sh "python -m compileall ."
}
}
stage('Unit tests') {
steps {
echo "-=- execute unit tests -=-"
sh "nosetests -v test"
}
}
stage('Mutation tests') {
steps {
echo "-=- execute mutation tests -=-"
// initialize mutation testing session
sh "cosmic-ray init config.yml jenkins_session && cosmic-ray --verbose exec jenkins_session && cosmic-ray dump jenkins_session | cr-report"
}
}
stage('Package') {
steps {
echo "-=- packaging project -=-"
echo "No packaging phase for python projects ..."
}
}
stage('Build Docker image') {
steps {
echo "-=- build Docker image -=-"
sh "docker build -t restalion/python-jenkins-pipeline:0.1 ."
}
}
stage('Run Docker image') {
steps {
echo "-=- run Docker image -=-"
sh "docker run --name python-jenkins-pipeline --detach --rm --network ci -p 5001:5000 restalion/python-jenkins-pipeline:0.1"
}
}
stage('Integration tests') {
steps {
echo "-=- execute integration tests -=-"
sh "nosetests -v int_test"
}
}
stage('Performance tests') {
steps {
echo "-=- execute performance tests -=-"
sh "locust -f ./perf_test/locustfile.py --no-web -c 1000 -r 100 --run-time 1m -H http://172.18.0.3:5001"
}
}
stage('Dependency vulnerability tests') {
steps {
echo "-=- run dependency vulnerability tests -=-"
sh "safety check"
}
}
stage('Code inspection & quality gate') {
steps {
echo "-=- run code inspection & quality gate -=-"
sh "pylama"
}
}
stage('Push Docker image') {
steps {
echo "-=- push Docker image -=-"
withDockerRegistry([ credentialsId: "werdar-wedartg-uiny67-adsuja0-12njkn3", url: "" ]) {
sh "docker push restalion/python-jenkins-pipeline:0.1"
}
//sh "mvn docker:push"
}
}
}
post {
always {
echo "-=- remove deployment -=-"
sh "docker stop python-jenkins-pipeline"
}
}
}