7bfda552dbc27770a7ae83c80cc7b82a2b1681d0
[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           docker_file: 'Dockerfile'
23       - 'arm64':
24           slave_label: 'opnfv-build-ubuntu-arm'
25           docker_file: '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           docker_file: 'Dockerfile'
81           arch_tag: 'amd64'
82
83     properties:
84       - throttle:
85           max-per-node: 1
86           option: 'project'
87
88     scm:
89       - git-scm
90
91     triggers:
92       - pollscm:
93           cron: "*/30 * * * *"
94
95     builders:
96       - multijob:
97           name: 'build compass-tasks-base images'
98           execution-type: PARALLEL
99           projects:
100             - name: 'compass-tasks-base-build-amd64-{stream}'
101               <<: *build-job-settings
102             - name: 'compass-tasks-base-build-arm64-{stream}'
103               <<: *build-job-settings
104       - multijob:
105           name: 'publish compass-tasks-base manifests'
106           execution-type: PARALLEL
107           projects:
108             - name: 'compass-tasks-base-manifest-{stream}'
109               <<: *manifest-job-settings
110       - multijob:
111           name: 'build all compass images'
112           condition: SUCCESSFUL
113           execution-type: PARALLEL
114           projects:
115             - name: 'compass-cobbler-build-amd64-{stream}'
116               <<: *build-job-settings
117             - name: 'compass-db-build-amd64-{stream}'
118               <<: *build-job-settings
119             - name: 'compass-deck-build-amd64-{stream}'
120               <<: *build-job-settings
121             - name: 'compass-tasks-build-amd64-{stream}'
122               <<: *build-job-settings
123             - name: 'compass-tasks-k8s-build-amd64-{stream}'
124               <<: *build-job-settings
125             - name: 'compass-tasks-osa-build-amd64-{stream}'
126               <<: *build-job-settings
127             - name: 'compass-cobbler-build-arm64-{stream}'
128               <<: *build-job-settings
129             - name: 'compass-db-build-arm64-{stream}'
130               <<: *build-job-settings
131             - name: 'compass-deck-build-arm64-{stream}'
132               <<: *build-job-settings
133             - name: 'compass-tasks-build-arm64-{stream}'
134               <<: *build-job-settings
135             - name: 'compass-tasks-k8s-build-arm64-{stream}'
136               <<: *build-job-settings
137             - name: 'compass-tasks-osa-build-arm64-{stream}'
138               <<: *build-job-settings
139       - multijob:
140           name: 'publish all manifests'
141           execution-type: PARALLEL
142           projects:
143             - name: 'compass-cobbler-manifest-{stream}'
144               <<: *manifest-job-settings
145             - name: 'compass-db-manifest-{stream}'
146               <<: *manifest-job-settings
147             - name: 'compass-deck-manifest-{stream}'
148               <<: *manifest-job-settings
149             - name: 'compass-tasks-manifest-{stream}'
150               <<: *manifest-job-settings
151             - name: 'compass-tasks-k8s-manifest-{stream}'
152               <<: *manifest-job-settings
153             - name: 'compass-tasks-osa-manifest-{stream}'
154               <<: *manifest-job-settings
155
156     publishers:
157       - 'compass-amd64-recipients'
158       - 'compass-arm64-recipients'
159
160 - job-template:
161     name: 'compass-{image}-build-{arch_tag}-{stream}'
162     disabled: '{obj:disabled}'
163     parameters:
164       - compass-job-parameters:
165           project: '{project}'
166           branch: '{branch}'
167           slave_label: '{slave_label}'
168           docker_file: '{docker_file}'
169           arch_tag: '{arch_tag}'
170       - string:
171           name: DOCKER_REPO_NAME
172           default: "opnfv/compass-{image}"
173           description: "Dockerhub repo to be pushed to."
174       - string:
175           name: DOCKER_DIR
176           default: "compass-{image}"
177           description: "Directory containing files needed by the Dockerfile"
178     scm:
179       - git-scm
180     builders:
181       - shell:
182           !include-raw-escape: ./opnfv-docker.sh
183
184 - job-template:
185     name: 'compass-{image}-manifest-{stream}'
186     disabled: '{obj:disabled}'
187     parameters:
188       - compass-job-parameters:
189           project: '{project}'
190           branch: '{branch}'
191           slave_label: 'opnfv-build-ubuntu'
192           docker_file: 'Dockerfile'
193           arch_tag: 'amd64'
194     builders:
195       - shell: |
196           #!/bin/bash -ex
197           case "{stream}" in
198           "master")
199               tag="latest" ;;
200           *)
201               tag="{stream}" ;;
202           esac
203           sudo manifest-tool push from-args \
204               --platforms linux/amd64,linux/arm64 \
205               --template opnfv/compass-{image}:ARCH-$tag \
206               --target opnfv/compass-{image}:$tag
207           exit $?
208
209 # parameter macro
210 - parameter:
211     name: compass-job-parameters
212     parameters:
213       - project-parameter:
214           project: '{project}'
215           branch: '{branch}'
216       - label:
217           name: SLAVE_LABEL
218           default: '{slave_label}'
219           description: 'Slave label on Jenkins'
220       - string:
221           name: GIT_BASE
222           default: https://gerrit.opnfv.org/gerrit/$PROJECT
223           description: 'Git URL to use on this Jenkins Slave'
224       - string:
225           name: PUSH_IMAGE
226           default: "true"
227           description: "To enable/disable pushing the image to Dockerhub."
228       - string:
229           name: COMMIT_ID
230           default: ""
231           description: "commit id to make a snapshot docker image"
232       - string:
233           name: GERRIT_REFNAME
234           default: ""
235           description: "Docker tag to be built, e.g. refs/tags/5.0.0, refs/tags/opnfv-5.0.0, refs/tags/5.0.RC1"
236       - string:
237           name: DOCKERFILE
238           default: '{docker_file}'
239           description: "Dockerfile to use for creating the image."
240       - string:
241           name: ARCH_TAG
242           default: "{arch_tag}"
243           description: "If set, this value will be added to the docker image tag as a prefix"
244       - string:
245           name: PROJECT
246           default: "{project}"
247           description: "Project name used to enable job conditions"
248
249 # publisher macros
250 - publisher:
251     name: 'compass-amd64-recipients'
252     publishers:
253       - email:
254           recipients: >
255             chigang@huawei.com
256             huangxiangyui5@huawei.com
257             xueyifei@huawei.com
258             wutianwei1@huawei.com
259
260 - publisher:
261     name: 'compass-arm64-recipients'
262     publishers:
263       - email:
264           recipients: >
265             yibo.cai@arm.com