forked from nutonomy/nuscenes-devkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
191 lines (179 loc) · 6.35 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
pipeline {
agent {
kubernetes {
label 'nuscenes-builder-' + UUID.randomUUID().toString()
yamlFile 'setup/docker.yaml'
}// kubernetes
} // agent
environment {
PROD_IMAGE = "nuscenes:production"
TEST_IMAGE_3_6 = "registry-local.nutonomy.team:5000/nuscenes-test:kube${UUID.nameUUIDFromBytes(new String(env.BUILD_TAG).getBytes())}"
TEST_IMAGE_3_7 = "registry-local.nutonomy.team:5000/nuscenes-test:kube${UUID.nameUUIDFromBytes(new String(env.BUILD_TAG).getBytes())}"
NUSCENES = "/data/sets/nuscenes"
}
stages {
stage('Build'){
steps {
container('docker') {
// Build the Docker image, and then run python -m unittest inside
// an activated Conda environment inside of the container.
sh """#!/bin/bash
set -eux
docker build -t $TEST_IMAGE_3_6 -f setup/Dockerfile_3.6 .
docker push $TEST_IMAGE_3_6
docker build -t $TEST_IMAGE_3_7 -f setup/Dockerfile_3.7 .
docker push $TEST_IMAGE_3_7
"""
} // container
} // steps
} // stage
stage('Tests') {
failFast true
parallel {
stage('Test 3.6'){
agent {
kubernetes {
label 'nuscenes-test3.6-' + UUID.randomUUID().toString()
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
app: nuscenes
spec:
containers:
- name: jnlp
image: registry.nutonomy.com:5000/nu/jnlp-slave:3.19-1-lfs
imagePullPolicy: Always
- name: docker
image: $TEST_IMAGE_3_6
command:
- cat
tty: true
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker
- mountPath: /data/
name: nudeep-ci
subPath: data
imagePullSecrets:
- name: regcredjenkins
volumes:
- name: docker
hostPath:
path: /var/run/docker.sock
- name: nudeep-ci
persistentVolumeClaim:
claimName: nudeep-ci
env:
- name: NUSCENES
value: $NUSCENES
"""
}// kubernetes
} // agent
steps {
container('docker') {
sh """#!/bin/bash
set -e
source activate nuscenes && python -m unittest discover python-sdk
bash setup/test_tutorial.sh
"""
} // container
} // steps
} // stage
stage('Test 3.7'){
agent {
kubernetes {
label 'nuscenes-test3.7-' + UUID.randomUUID().toString()
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
app: nuscenes
spec:
containers:
- name: jnlp
image: registry.nutonomy.com:5000/nu/jnlp-slave:3.19-1-lfs
imagePullPolicy: Always
- name: docker
image: $TEST_IMAGE_3_7
command:
- cat
tty: true
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker
- mountPath: /data/
name: nudeep-ci
subPath: data
imagePullSecrets:
- name: regcredjenkins
volumes:
- name: docker
hostPath:
path: /var/run/docker.sock
- name: nudeep-ci
persistentVolumeClaim:
claimName: nudeep-ci
env:
- name: NUSCENES
value: $NUSCENES
"""
}// kubernetes
} // agent
steps {
container('docker') {
sh """#!/bin/bash
set -e
source activate nuscenes && python -m unittest discover python-sdk
bash setup/test_tutorial.sh
"""
} // container
} // steps
} // stage
} // parallel
} // stage
stage('Deploy') {
when {
branch 'master'
}
steps {
// TODO: determine where to deploy Docker images.
container('docker'){
withCredentials([[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: 'aws-ecr-staging',
]]){
sh """#!/bin/bash
echo 'Tagging docker image as ready for production. For now, this stage of the pipeline does nothing.'
# docker build -t $PROD_IMAGE .
# docker push $PROD_IMAGE
"""
}
} // container('docker')
} //steps
} // stage('Deploy')
} // stages
post {
// only clean up if the build was successful; this allows us to debug failed builds
success {
// sh """git clean -fdx"""
slackSend channel: "#nuscenes-ci", token: "bWyF0sJAVlMPOTs2lUTt5c2N", color: "#00cc00", message: """Success ${env.JOB_NAME} #${env.BUILD_NUMBER} [${env.CHANGE_AUTHOR}] (<${env.BUILD_URL}|Open>)
${env.CHANGE_BRANCH}: ${env.CHANGE_TITLE}"""
}
aborted {
slackSend channel: "#nuscenes-ci", token: "bWyF0sJAVlMPOTs2lUTt5c2N", color: "#edb612", message: """Aborted ${env.JOB_NAME} #${env.BUILD_NUMBER} [${env.CHANGE_AUTHOR}] (<${env.BUILD_URL}|Open>)
${env.CHANGE_BRANCH}: ${env.CHANGE_TITLE}"""
}
failure {
slackSend channel: "#nuscenes-ci", token: "bWyF0sJAVlMPOTs2lUTt5c2N", color: "#c61515", message: """Failed ${env.JOB_NAME} #${env.BUILD_NUMBER} [${env.CHANGE_AUTHOR}] (<${env.BUILD_URL}|Open>)
${env.CHANGE_BRANCH}: ${env.CHANGE_TITLE}"""
}
//changed {
// only run if the current Pipeline run has a different status from previously completed Pipeline
//}
} // post
} // Pipeline