Docker Builds from Git Tag
[releng.git] / jjb / releng / functest-docker.yml
1 ---
2 ##############################################
3 # job configuration for docker build and push
4 ##############################################
5 - project:
6
7     name: functest-docker
8
9     project: functest
10
11     stream:
12       - master:
13           branch: '{stream}'
14           disabled: false
15       - euphrates:
16           branch: 'stable/{stream}'
17           disabled: false
18
19     arch_tag:
20       - 'amd64':
21           slave_label: 'opnfv-build-ubuntu'
22       - 'arm64':
23           slave_label: 'opnfv-build-ubuntu-arm'
24
25     # yamllint disable rule:key-duplicates
26     image:
27       - 'core'
28       - 'healthcheck'
29       - 'features'
30       - 'components'
31       - 'parser'
32       - 'smoke'
33       - 'vnf'
34       - 'restapi'
35
36     # settings for jobs run in multijob phases
37     build-job-settings: &build-job-settings
38       current-parameters: false
39       git-revision: true
40       node-parameters: false
41       predefined-parameters: |
42         PUSH_IMAGE=$PUSH_IMAGE
43         COMMIT_ID=$COMMIT_ID
44         GERRIT_REFNAME=$GERRIT_REFNAME
45         DOCKERFILE=$DOCKERFILE
46       kill-phase-on: FAILURE
47       abort-all-jobs: false
48
49     manifest-job-settings: &manifest-job-settings
50       current-parameters: false
51       git-revision: true
52       node-parameters: false
53       predefined-parameters:
54         GERRIT_REFNAME=$GERRIT_REFNAME
55       kill-phase-on: FAILURE
56       abort-all-jobs: false
57
58     # yamllint enable rule:key-duplicates
59     jobs:
60       - "functest-docker-{stream}"
61       - "functest-{image}-build-{arch_tag}-{stream}"
62       - "functest-{image}-manifest-{stream}"
63
64 ########################
65 # job templates
66 ########################
67 - job-template:
68     name: 'functest-docker-{stream}'
69
70     project-type: multijob
71
72     disabled: '{obj:disabled}'
73
74     parameters:
75       - job-parameters:
76           project: '{project}'
77           branch: '{branch}'
78           slave_label: 'opnfv-build-ubuntu'
79           arch_tag: 'amd64'
80
81     properties:
82       - throttle:
83           max-per-node: 1
84           option: 'project'
85
86     scm:
87       - git-scm
88
89     triggers:
90       - pollscm:
91           cron: "*/30 * * * *"
92       - gerrit-trigger-tag-created:
93           project: '{project}'
94
95     builders:
96       - multijob:
97           name: 'build functest-core images'
98           execution-type: PARALLEL
99           projects:
100             - name: 'functest-core-build-amd64-{stream}'
101               <<: *build-job-settings
102             - name: 'functest-core-build-arm64-{stream}'
103               <<: *build-job-settings
104       - multijob:
105           name: 'publish functest-core manifests'
106           execution-type: PARALLEL
107           projects:
108             - name: 'functest-core-manifest-{stream}'
109               <<: *manifest-job-settings
110       - multijob:
111           name: 'build all functest images'
112           condition: SUCCESSFUL
113           execution-type: PARALLEL
114           projects:
115             - name: 'functest-healthcheck-build-amd64-{stream}'
116               <<: *build-job-settings
117             - name: 'functest-healthcheck-build-arm64-{stream}'
118               <<: *build-job-settings
119             - name: 'functest-features-build-amd64-{stream}'
120               <<: *build-job-settings
121             - name: 'functest-features-build-arm64-{stream}'
122               <<: *build-job-settings
123             - name: 'functest-components-build-amd64-{stream}'
124               <<: *build-job-settings
125             - name: 'functest-components-build-arm64-{stream}'
126               <<: *build-job-settings
127             - name: 'functest-parser-build-amd64-{stream}'
128               <<: *build-job-settings
129             - name: 'functest-parser-build-arm64-{stream}'
130               <<: *build-job-settings
131             - name: 'functest-smoke-build-amd64-{stream}'
132               <<: *build-job-settings
133             - name: 'functest-smoke-build-arm64-{stream}'
134               <<: *build-job-settings
135             - name: 'functest-vnf-build-amd64-{stream}'
136               <<: *build-job-settings
137             - name: 'functest-restapi-build-amd64-{stream}'
138               <<: *build-job-settings
139       - multijob:
140           name: 'publish all manifests'
141           condition: SUCCESSFUL
142           execution-type: PARALLEL
143           projects:
144             - name: 'functest-healthcheck-manifest-{stream}'
145               <<: *manifest-job-settings
146             - name: 'functest-features-manifest-{stream}'
147               <<: *manifest-job-settings
148             - name: 'functest-components-manifest-{stream}'
149               <<: *manifest-job-settings
150             - name: 'functest-parser-manifest-{stream}'
151               <<: *manifest-job-settings
152             - name: 'functest-smoke-manifest-{stream}'
153               <<: *manifest-job-settings
154             - name: 'functest-vnf-manifest-{stream}'
155               <<: *manifest-job-settings
156             - name: 'functest-restapi-manifest-{stream}'
157               <<: *manifest-job-settings
158
159     publishers:
160       - 'functest-amd64-recipients'
161       - 'functest-arm64-recipients'
162
163 - job-template:
164     name: 'functest-{image}-build-{arch_tag}-{stream}'
165     disabled: '{obj:disabled}'
166     parameters:
167       - job-parameters:
168           project: '{project}'
169           branch: '{branch}'
170           slave_label: '{slave_label}'
171           arch_tag: '{arch_tag}'
172     scm:
173       - git-scm
174     builders:
175       - shell: |
176           #!/bin/bash -ex
177           case "{arch_tag}" in
178           "arm64")
179               sudo amd64_dirs= arm64_dirs=docker/{image} bash ./build.sh ;;
180           *)
181               sudo amd64_dirs=docker/{image} arm64_dirs= bash ./build.sh ;;
182           esac
183           exit $?
184
185 - job-template:
186     name: 'functest-{image}-manifest-{stream}'
187
188     parameters:
189       - project-parameter:
190           project: '{project}'
191           branch: '{branch}'
192       - label:
193           name: SLAVE_LABEL
194           default: 'opnfv-build-ubuntu'
195           description: 'Slave label on Jenkins'
196       - string:
197           name: PROJECT
198           default: "{project}"
199           description: "Project name used to enable job conditions"
200       - string:
201           name: GIT_BASE
202           default: https://gerrit.opnfv.org/gerrit/$PROJECT
203           description: 'Git URL to use on this Jenkins Slave'
204
205     disabled: '{obj:disabled}'
206
207     builders:
208       - shell: |
209           #!/bin/bash -ex
210           case "{stream}" in
211           "master")
212               tag="latest" ;;
213           *)
214               tag="{stream}" ;;
215           esac
216           case "{image}" in
217           "vnf"|"restapi")
218               sudo manifest-tool push from-args \
219                   --platforms linux/amd64 \
220                   --template opnfv/functest-{image}:ARCH-$tag \
221                   --target opnfv/functest-{image}:$tag ;;
222           *)
223               sudo manifest-tool push from-args \
224                   --platforms linux/amd64,linux/arm64 \
225                   --template opnfv/functest-{image}:ARCH-$tag \
226                   --target opnfv/functest-{image}:$tag ;;
227           esac
228           exit $?
229
230 # parameter macro
231 - parameter:
232     name: job-parameters
233     parameters:
234       - project-parameter:
235           project: '{project}'
236           branch: '{branch}'
237       - label:
238           name: SLAVE_LABEL
239           default: '{slave_label}'
240           description: 'Slave label on Jenkins'
241       - string:
242           name: GIT_BASE
243           default: https://gerrit.opnfv.org/gerrit/$PROJECT
244           description: 'Git URL to use on this Jenkins Slave'
245       - string:
246           name: PUSH_IMAGE
247           default: "true"
248           description: "To enable/disable pushing the image to Dockerhub."
249       - string:
250           name: COMMIT_ID
251           default: ""
252           description: "commit id to make a snapshot docker image"
253       - string:
254           name: GERRIT_REFNAME
255           default: ""
256           description: "Docker tag to be built, e.g. refs/tags/5.0.0, refs/tags/opnfv-5.0.0, refs/tags/5.0.RC1"
257       - string:
258           name: DOCKERFILE
259           default: "Dockerfile"
260           description: "Dockerfile to use for creating the image."
261       - string:
262           name: ARCH_TAG
263           default: "{arch_tag}"
264           description: "If set, this value will be added to the docker image tag as a prefix"
265       - string:
266           name: PROJECT
267           default: "{project}"
268           description: "Project name used to enable job conditions"
269
270 # publisher macros
271 - publisher:
272     name: 'functest-arm64-recipients'
273     publishers:
274       - email:
275           recipients: >
276             cristina.pauna@enea.com
277             alexandru.avadanii@enea.com
278             delia.popescu@enea.com
279
280 - publisher:
281     name: 'functest-amd64-recipients'
282     publishers:
283       - email:
284           recipients: >
285             jalausuch@suse.com morgan.richomme@orange.com
286             cedric.ollivier@orange.com feng.xiaowei@zte.com.cn
287             juha.kosonen@nokia.com wangwulin@huawei.com