forked from Substra/substra-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
165 lines (143 loc) · 4.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
pipeline {
options {
timestamps ()
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '5'))
}
parameters {
booleanParam(name: 'E2E', defaultValue: false, description: 'Launch E2E test')
string(name: 'CLI', defaultValue: 'dev', description: 'substra branch')
string(name: 'CHAINCODE', defaultValue: 'dev', description: 'chaincode branch')
}
agent none
stages {
stage('Abort previous builds'){
steps {
milestone(Integer.parseInt(env.BUILD_ID)-1)
milestone(Integer.parseInt(env.BUILD_ID))
}
}
stage('Test & Build') {
parallel {
stage('Test Helm') {
agent {
kubernetes {
label 'substra-backend-helm'
defaultContainer 'helm'
yamlFile '.cicd/agent-helm.yaml'
}
}
steps {
sh "helm lint charts/substra-backend"
}
}
stage('Test') {
agent {
kubernetes {
label 'substra-backend-test'
defaultContainer 'python'
yamlFile '.cicd/agent-python.yaml'
}
}
steps {
sh "apt update"
sh "apt install curl && mkdir -p /tmp/download && curl -L https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz | tar -xz -C /tmp/download && mv /tmp/download/docker/docker /usr/local/bin/"
sh "docker login -u _json_key --password-stdin https://eu.gcr.io/substra-208412/ < /secret/kaniko-secret.json"
sh "apt install -y python3-pip python3-dev build-essential gfortran musl-dev postgresql-contrib git curl netcat"
dir("backend") {
sh "pip install flake8"
sh "flake8"
sh "pip install -r requirements.txt"
sh "DJANGO_SETTINGS_MODULE=backend.settings.test coverage run manage.py test"
sh "coverage report"
sh "coverage html"
}
}
post {
success {
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'backend/htmlcov',
reportFiles: 'index.html',
reportName: 'Coverage Report'
]
}
}
}
stage('Build substra-backend') {
agent {
kubernetes {
label 'substra-backend-kaniko-substra-backend'
yamlFile '.cicd/agent-kaniko.yaml'
}
}
steps {
container(name:'kaniko', shell:'/busybox/sh') {
sh '''#!/busybox/sh
/kaniko/executor -f `pwd`/docker/substra-backend/Dockerfile -c `pwd` -d "eu.gcr.io/substra-208412/substra-backend:$GIT_COMMIT"
'''
}
}
}
stage('Build celerybeat') {
agent {
kubernetes {
label 'substra-backend-kaniko-celerybeat'
yamlFile '.cicd/agent-kaniko.yaml'
}
}
steps {
container(name:'kaniko', shell:'/busybox/sh') {
sh '''#!/busybox/sh
/kaniko/executor -f `pwd`/docker/celerybeat/Dockerfile -c `pwd` -d "eu.gcr.io/substra-208412/celerybeat:$GIT_COMMIT"
'''
}
}
}
stage('Build celeryworker') {
agent {
kubernetes {
label 'substra-backend-kaniko-celeryworker'
yamlFile '.cicd/agent-kaniko.yaml'
}
}
steps {
container(name:'kaniko', shell:'/busybox/sh') {
sh '''#!/busybox/sh
/kaniko/executor -f `pwd`/docker/celeryworker/Dockerfile -c `pwd` -d "eu.gcr.io/substra-208412/celeryworker:$GIT_COMMIT"
'''
}
}
}
stage('Publish Helm') {
agent {
kubernetes {
label 'substra-backend-helm'
defaultContainer 'helm'
yamlFile '.cicd/agent-helm.yaml'
}
}
when { buildingTag() }
steps {
sh "helm init --client-only"
sh "helm plugin install https://github.com/chartmuseum/helm-push"
sh "helm repo add substra https://substra-charts.owkin.com --username owlways --password Cokear4nnRK9ooC"
sh "helm push charts/substra-backend substra || true"
}
}
}
}
stage('Test with hlf-k8s') {
when {
expression { return params.E2E }
}
steps {
build job: 'hlf-k8s/dev', parameters: [string(name: 'BACKEND', value: env.CHANGE_BRANCH),
string(name: 'CHAINCODE', value: params.CHAINCODE),
string(name: 'CLI', value: params.CLI)], propagate: true
}
}
}
}