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