jjb/releng: support multi arch compass images
[releng.git] / jjb / releng / compass4nfv-docker.yaml
1 ---
2 ##############################################
3 # job configuration for docker build and push
4 ##############################################
5 - project:
6
7     name: compass-docker
8
9     project: compass-containers
10
11     stream:
12       - master:
13           branch: '{stream}'
14           disabled: false
15       - euphrates:
16           branch: 'stable/{stream}'
17           disabled: true
18
19     arch_tag:
20       - 'amd64':
21           slave_label: 'opnfv-build-ubuntu'
22           dockerfile: 'Dockerfile'
23       - 'arm64':
24           slave_label: 'opnfv-build-ubuntu-arm'
25           dockerfile: 'Dockerfile-arm64'
26
27     # yamllint disable rule:key-duplicates
28     image:
29       - 'tasks'
30       - 'cobbler'
31       - 'db'
32       - 'deck'
33       - 'tasks-base'
34       - 'tasks-k8s'
35       - 'tasks-osa'
36
37     # settings for jobs run in multijob phases
38     build-job-settings: &build-job-settings
39       current-parameters: false
40       git-revision: true
41       node-parameters: false
42       predefined-parameters: |
43         PUSH_IMAGE=$PUSH_IMAGE
44         COMMIT_ID=$COMMIT_ID
45         GERRIT_REFNAME=$GERRIT_REFNAME
46         DOCKERFILE=$DOCKERFILE
47       kill-phase-on: FAILURE
48       abort-all-jobs: false
49
50     manifest-job-settings: &manifest-job-settings
51       current-parameters: false
52       git-revision: true
53       node-parameters: false
54       predefined-parameters:
55         GERRIT_REFNAME=$GERRIT_REFNAME
56       kill-phase-on: FAILURE
57       abort-all-jobs: false
58
59     # yamllint enable rule:key-duplicates
60     jobs:
61       - "compass-docker-{stream}"
62       - "compass-{image}-build-{arch_tag}-{stream}"
63       - "compass-{image}-manifest-{stream}"
64
65 ########################
66 # job templates
67 ########################
68 - job-template:
69     name: 'compass-docker-{stream}'
70
71     project-type: multijob
72
73     disabled: '{obj:disabled}'
74
75     parameters:
76       - compass-job-parameters:
77           project: '{project}'
78           branch: '{branch}'
79           slave_label: 'opnfv-build-ubuntu'
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
93     builders:
94       - multijob:
95           name: 'build compass-tasks-base images'
96           execution-type: PARALLEL
97           projects:
98             - name: 'compass-tasks-base-build-amd64-{stream}'
99               <<: *build-job-settings
100             - name: 'compass-tasks-base-build-arm64-{stream}'
101               <<: *build-job-settings
102       - multijob:
103           name: 'publish compass-tasks-base manifests'
104           execution-type: PARALLEL
105           projects:
106             - name: 'compass-tasks-base-manifest-{stream}'
107               <<: *manifest-job-settings
108       - multijob:
109           name: 'build all compass images'
110           condition: SUCCESSFUL
111           execution-type: PARALLEL
112           projects:
113             - name: 'compass-cobbler-build-amd64-{stream}'
114               <<: *build-job-settings
115             - name: 'compass-db-build-amd64-{stream}'
116               <<: *build-job-settings
117             - name: 'compass-deck-build-amd64-{stream}'
118               <<: *build-job-settings
119             - name: 'compass-tasks-build-amd64-{stream}'
120               <<: *build-job-settings
121             - name: 'compass-tasks-k8s-build-amd64-{stream}'
122               <<: *build-job-settings
123             - name: 'compass-tasks-osa-build-amd64-{stream}'
124               <<: *build-job-settings
125             - name: 'compass-cobbler-build-arm64-{stream}'
126               <<: *build-job-settings
127             - name: 'compass-db-build-arm64-{stream}'
128               <<: *build-job-settings
129             - name: 'compass-deck-build-arm64-{stream}'
130               <<: *build-job-settings
131             - name: 'compass-tasks-build-arm64-{stream}'
132               <<: *build-job-settings
133             - name: 'compass-tasks-k8s-build-arm64-{stream}'
134               <<: *build-job-settings
135             - name: 'compass-tasks-osa-build-arm64-{stream}'
136               <<: *build-job-settings
137       - multijob:
138           name: 'publish all manifests'
139           execution-type: PARALLEL
140           projects:
141             - name: 'compass-cobbler-manifest-{stream}'
142               <<: *manifest-job-settings
143             - name: 'compass-db-manifest-{stream}'
144               <<: *manifest-job-settings
145             - name: 'compass-deck-manifest-{stream}'
146               <<: *manifest-job-settings
147             - name: 'compass-tasks-manifest-{stream}'
148               <<: *manifest-job-settings
149             - name: 'compass-tasks-k8s-manifest-{stream}'
150               <<: *manifest-job-settings
151             - name: 'compass-tasks-osa-manifest-{stream}'
152               <<: *manifest-job-settings
153
154     publishers:
155       - 'compass-amd64-recipients'
156       - 'compass-arm64-recipients'
157
158 - job-template:
159     name: 'compass-{image}-build-{arch_tag}-{stream}'
160     disabled: '{obj:disabled}'
161     parameters:
162       - compass-job-parameters:
163           project: '{project}'
164           branch: '{branch}'
165           slave_label: '{slave_label}'
166       - string:
167           name: DOCKER_REPO_NAME
168           default: "opnfv/compass-{image}"
169           description: "Dockerhub repo to be pushed to."
170       - string:
171           name: DOCKER_DIR
172           default: "compass-{image}"
173           description: "Directory containing files needed by the Dockerfile"
174       - string:
175           name: DOCKERFILE
176           default: '{dockerfile}'
177           description: "Dockerfile to use for creating the image."
178       - string:
179           name: ARCH_TAG
180           default: "{arch_tag}"
181           description: "If set, this value will be added to the docker image tag as a prefix"
182     scm:
183       - git-scm
184     builders:
185       - shell:
186           !include-raw-escape: ./opnfv-docker.sh
187
188 - job-template:
189     name: 'compass-{image}-manifest-{stream}'
190     disabled: '{obj:disabled}'
191     parameters:
192       - compass-job-parameters:
193           project: '{project}'
194           branch: '{branch}'
195           slave_label: 'opnfv-build-ubuntu'
196     builders:
197       - shell: |
198           #!/bin/bash -ex
199           case "{stream}" in
200           "master")
201               tag="latest" ;;
202           *)
203               tag="{stream}" ;;
204           esac
205           sudo manifest-tool push from-args \
206               --platforms linux/amd64,linux/arm64 \
207               --template opnfv/compass-{image}:ARCH-$tag \
208               --target opnfv/compass-{image}:$tag
209           exit $?
210
211 # parameter macro
212 - parameter:
213     name: compass-job-parameters
214     parameters:
215       - project-parameter:
216           project: '{project}'
217           branch: '{branch}'
218       - label:
219           name: SLAVE_LABEL
220           default: '{slave_label}'
221           description: 'Slave label on Jenkins'
222       - string:
223           name: GIT_BASE
224           default: https://gerrit.opnfv.org/gerrit/$PROJECT
225           description: 'Git URL to use on this Jenkins Slave'
226       - string:
227           name: PUSH_IMAGE
228           default: "true"
229           description: "To enable/disable pushing the image to Dockerhub."
230       - string:
231           name: COMMIT_ID
232           default: ""
233           description: "commit id to make a snapshot docker image"
234       - string:
235           name: GERRIT_REFNAME
236           default: ""
237           description: "Docker tag to be built, e.g. refs/tags/5.0.0, refs/tags/opnfv-5.0.0, refs/tags/5.0.RC1"
238       - string:
239           name: PROJECT
240           default: "{project}"
241           description: "Project name used to enable job conditions"
242
243 # publisher macros
244 - publisher:
245     name: 'compass-amd64-recipients'
246     publishers:
247       - email:
248           recipients: >
249             chigang@huawei.com
250             huangxiangyui5@huawei.com
251             xueyifei@huawei.com
252             wutianwei1@huawei.com
253
254 - publisher:
255     name: 'compass-arm64-recipients'
256     publishers:
257       - email:
258           recipients: >
259             yibo.cai@arm.com