This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
182 lines (158 loc) · 6.41 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
#!/usr/bin/groovy
@Library(['github.com/indigo-dc/[email protected]']) _
// define which TensorFlow versions to use
def getTFVers(){
return ["2.9.3", "2.10.0", "2.11.0", "2.12.0", "2.13.0"]
}
def getPyTorchTags(){
return ["1.11.0-cuda11.3-cudnn8-runtime", "1.12.0-cuda11.3-cudnn8-runtime", "1.13.0-cuda11.6-cudnn8-runtime", "2.0.0-cuda11.7-cudnn8-runtime", "2.1.0-cuda11.8-cudnn8-runtime"]
}
def getPyTorchVers(){
return ["1.11", "1.12", "1.13", "2.0", "2.1"]
}
pipeline {
agent {
label 'docker-build'
}
environment {
dockerhub_repo = "deephdc/deep-oc-generic-dev"
}
stages {
stage('Validate metadata') {
steps {
checkout scm
sh 'deep-app-schema-validator metadata.json'
}
}
stage('Docker image building (pytorch)') {
when {
anyOf {
branch 'master'
buildingTag()
}
}
steps{
checkout scm
script {
// build different tags
id = "${env.dockerhub_repo}"
// pyTorch
pytorch_tags = getPyTorchTags()
pytorch_vers = getPyTorchVers()
p_vers = pytorch_vers.size()
// CAREFUL! For-loop might fail in some Jenkins versions
// Other options:
// https://stackoverflow.com/questions/37594635/why-an-each-loop-in-a-jenkinsfile-stops-at-first-iteration
for(int j=0; j < p_vers; j++) {
tag_id = ['pytorch'+pytorch_vers[j]]
pytorch_tag = pytorch_tags[j]
id_pytorch = DockerBuild(id,
tag: tag_id,
build_args: ["image=pytorch/pytorch",
"tag=${pytorch_tag}"])
DockerPush(id_pytorch)
// immediately remove local image
id_this = id_pytorch[0]
sh("docker rmi --force \$(docker images -q ${id_this})")
}
}
}
post {
failure {
DockerClean()
}
}
}
stage('Docker image building (tensorflow)') {
when {
anyOf {
branch 'master'
buildingTag()
}
}
steps{
checkout scm
script {
// build different tags
id = "${env.dockerhub_repo}"
// TensorFlow
tf_vers = getTFVers()
n_vers = tf_vers.size()
// CAREFUL! For-loop might fail in some Jenkins versions
// Other options:
// https://stackoverflow.com/questions/37594635/why-an-each-loop-in-a-jenkinsfile-stops-at-first-iteration
for(int j=0; j < n_vers; j++) {
tags = ['tf'+tf_vers[j]+'-cpu',
'tf'+tf_vers[j]+'-gpu']
tf_tags = [tf_vers[j],
tf_vers[j]+'-gpu']
for(int i=0; i < tags.size(); i++) {
tag_id = [tags[i]]
// tag last cpu tag as "latest"
if (j == (n_vers - 1) && tags[i].contains("-cpu")) {
tag_id = [tags[i], 'latest']
}
// tag last gpu tag as "latest-gpu"
if (j == (n_vers - 1) && tags[i].contains("-gpu")) {
tag_id = [tags[i], 'latest-gpu']
}
tf_tag = tf_tags[i]
id_docker = DockerBuild(id,
tag: tag_id,
build_args: ["image=tensorflow/tensorflow",
"tag=${tf_tag}"])
DockerPush(id_docker)
// immediately remove local image
id_this = id_docker[0]
sh("docker rmi --force \$(docker images -q ${id_this})")
//sh("docker rmi --force \$(docker images -q tensorflow/tensorflow:${tf_tag})")
}
}
}
}
post {
failure {
DockerClean()
}
}
}
stage('Docker image building (ubuntu)') {
when {
anyOf {
branch 'master'
buildingTag()
}
}
steps{
checkout scm
script {
// build different tags
id = "${env.dockerhub_repo}"
// Finally, we put all AI4OS components in
// ubuntu 20.04 image without deep learning framework
id_u2004 = DockerBuild(id,
tag: ['u20.04'],
build_args: ["image=ubuntu",
"tag=20.04"])
DockerPush(id_u2004)
id_u2204 = DockerBuild(id,
tag: ['u22.04'],
build_args: ["image=ubuntu",
"tag=22.04"])
DockerPush(id_u2204)
// immediately remove local image
id_this = id_u2004[0]
sh("docker rmi --force \$(docker images -q ${id_this})")
id_this = id_u2204[0]
sh("docker rmi --force \$(docker images -q ${id_this})")
//sh("docker rmi --force \$(docker images -q ubuntu:18.04)")
}
}
post {
failure {
DockerClean()
}
}
}
}
}