Revert "CI: Rename global-settings to mvn-glob..."
[ci-management.git] / jjb / akraino-templates / akraino-ta-common-macros.yaml
1 ---
2 # yamllint disable-file
3 ##############
4 # PARAMETERS #
5 ##############
6 - parameter:
7     name: ta-parameters
8     parameters:
9       - string:
10           name: SCM_REFSPEC_MANIFEST
11           default: refs/heads/master
12           description: ""
13           trim: "false"
14       - string:
15           name: SCM_REFSPEC_BUILD_TOOLS
16           default: refs/heads/master
17           description: ""
18           trim: "false"
19       - string:
20           name: SCM_REFSPEC_RPMBUILDER
21           default: refs/heads/master
22           description: ""
23           trim: "false"
24       - string:
25           name: SCM_PROJECT_TO_BUILD
26           default: ta/yarf
27           description: ""
28           trim: "false"
29       - string:
30           name: SCM_PROJECT_TO_BUILD_REFSPEC
31           default: refs/heads/master
32           description: ""
33           trim: "false"
34
35 #######
36 # SCM #
37 #######
38 - scm:
39     # Enhanced version of the global-jjb
40     name: ta-lf-infra-gerrit-scm
41     scm:
42       - git:
43           credentials-id: "{jenkins-ssh-credential}"
44           url: "{git-url}"
45           refspec: "{refspec}"
46           branches:
47             - "refs/heads/{branch}"
48           skip-tag: true
49           wipe-workspace: true
50           submodule:
51             recursive: "{submodule-recursive}"
52             timeout: "{submodule-timeout}"
53           choosing-strategy: "{choosing-strategy}"
54           basedir: "{basedir}"
55
56 - scm:
57     name: ta-lf-infra-gerrit-scm-merge
58     scm:
59       - ta-lf-infra-gerrit-scm:
60           jenkins-ssh-credential: "{jenkins-ssh-credential}"
61           git-url: "{git-url}"
62           refspec: "{refspec}"
63           branch: "{branch}"
64           submodule-recursive: "{submodule-recursive}"
65           submodule-timeout: "{submodule-timeout}"
66           basedir: "{basedir}"
67           choosing-strategy: default
68
69 - scm:
70     name: ta-lf-infra-gerrit-scm-verify
71     scm:
72       - ta-lf-infra-gerrit-scm:
73           jenkins-ssh-credential: "{jenkins-ssh-credential}"
74           git-url: "{git-url}"
75           refspec: "{refspec}"
76           branch: "{branch}"
77           submodule-recursive: "{submodule-recursive}"
78           submodule-timeout: "{submodule-timeout}"
79           basedir: "{basedir}"
80           choosing-strategy: gerrit
81
82 ###########
83 # BUILDER #
84 ###########
85 - builder:
86     name: lf-display-node-uuid
87     builders:
88       # yamllint disable rule:line-length
89       - shell: |2-
90             echo "---> Node UUID:"
91             curl -s http://169.254.169.254/openstack/latest/meta_data.json | python -c 'import sys, json; data = json.load(sys.stdin); print(data["uuid"])' || true
92       # yamllint enable rule:line-length
93
94 - builder:
95     name: ta-builder-tox
96     builders:
97       - shell: |2-
98           #!/bin/bash -ex
99           source ~/lf-env.sh
100
101           lf-activate-venv tox
102           tox --version
103           for f in $(find $GERRIT_PROJECT -name tox.ini); do
104               pushd $(dirname $f)
105               tox
106               popd
107           done
108
109 - builder:
110     name: ta-builder-rpm
111     builders:
112       - shell: |2-
113           #!/bin/bash -ex
114           #  Skip RPM build in case no *.spec file is found within the {project-to-build}
115           if [ -n "$(find {project-to-build} -name '*.spec')" ]; then
116               if apt --version >/dev/null 2>&1; then
117                   # We need a specific version of mock (1.4.14) and devtools
118                   # not available in Ubuntu/Debian repos, so fetch them from RHEL mirrors
119                   if [ "$(mock --version 2>/dev/null)" != '1.4.14' ]; then
120                       sudo groupadd mock || true
121                       sudo usermod -aG mock $USER
122                       sudo apt update
123                       # Explicitly install mock dependencies
124                       sudo apt install -y createrepo alien systemd-container python-pip \
125                                           python-peak.util.decorators yum-utils usermode pigz
126                       wget http://vault.centos.org/centos/7.6.1810/os/x86_64/Packages/rpmdevtools-8.3-5.el7.noarch.rpm \
127                            https://kojipkgs.fedoraproject.org/packages/mock/1.4.14/2.el7/noarch/mock-1.4.14-2.el7.noarch.rpm
128                       sudo alien -d *.rpm
129                       sudo dpkg --force-overwrite -i *.deb
130                       rm -rf *.rpm *.deb
131                       # RHEL tools hardcode the full path for certain distro tools
132                       sudo ln -sf /bin/tar /usr/bin/gtar
133                       sudo ln -sf /bin/machinectl /bin/df /usr/bin/
134                       # Some mock dependencies are only available via pip
135                       sudo pip install distro pyroute2 lxml urllib3
136                   fi
137               else
138                   sudo yum install -y createrepo
139               fi
140               ta/build-tools/build_rpms.sh \
141                -m ta/manifest \
142                -r ta/rpmbuilder \
143                -w work \
144                {project-to-build}
145               find work/
146           fi
147
148 - builder:
149     name: ta-builder-scm
150     builders:
151       - shell: |2-
152           #!/bin/bash -ex
153           rm -rf {project}
154           git clone {git-url}/{project} {project}
155           pushd {project}
156           if echo {ref} | grep -q "refs/"; then
157               git fetch origin {ref}
158               git checkout FETCH_HEAD
159           else
160               git checkout {ref}
161           fi
162           popd
163
164 - builder:
165     name: ta-lf-infra-ship-rpms
166     builders:
167       # Ensure no pre-existing .netrc files are overriding logs config
168       - lf-provide-maven-settings-cleanup
169       - config-file-provider:
170           files:
171             - file-id: "ta-settings"
172               variable: "SETTINGS_FILE"
173       - inject:
174           properties-content: "ALT_NEXUS_URL=https://nexus3.akraino.org"
175       - lf-infra-create-netrc:
176           server-id: rpm.snapshots
177       - inject:
178           properties-content: |
179             ALT_NEXUS_URL=
180             SERVER_ID=
181       - shell: !include-raw-escape:
182           # Ensure python-tools are installed in case job template does not
183           # call the lf-infra-pre-build macro.
184           - ../../global-jjb/shell/python-tools-install.sh
185       - shell: !include-raw-escape:
186           - ../shell/ta-rpm-deploy.sh
187       - shell: !include-raw-escape:
188           - ../../global-jjb/shell/logs-clear-credentials.sh
189
190 - builder:
191     name: ta-lf-infra-ship-isos
192     builders:
193       # Ensure no pre-existing .netrc files are overriding logs config
194       - lf-provide-maven-settings-cleanup
195       - config-file-provider:
196           files:
197             - file-id: "ta-settings"
198               variable: "SETTINGS_FILE"
199       - lf-infra-create-netrc:
200           server-id: images-snapshots
201       - shell: !include-raw-escape:
202           # Ensure python-tools are installed in case job template does not
203           # call the lf-infra-pre-build macro.
204           - ../../global-jjb/shell/python-tools-install.sh
205       - shell: !include-raw-escape:
206           - ../shell/ta-iso-deploy.sh
207       - shell: !include-raw-escape:
208           - ../../global-jjb/shell/logs-clear-credentials.sh
209
210 - builder:
211     name: ta-builder-job-verify
212     builders:
213       - ta-builder-scm:
214           git-url: "{git-url}"
215           project: "ta/manifest"
216           ref: "$SCM_REFSPEC_MANIFEST"
217       - ta-builder-scm:
218           git-url: "{git-url}"
219           project: "ta/build-tools"
220           ref: "$SCM_REFSPEC_BUILD_TOOLS"
221       - ta-builder-scm:
222           git-url: "{git-url}"
223           project: "ta/rpmbuilder"
224           ref: "$SCM_REFSPEC_RPMBUILDER"
225       - ta-builder-tox
226       - ta-builder-rpm:
227           project-to-build: "$GERRIT_PROJECT"
228
229 - builder:
230     name: ta-builder-job-verify-ta/rpmbuilder
231     builders:
232       - ta-builder-scm:
233           git-url: "{git-url}"
234           project: "ta/manifest"
235           ref: "$SCM_REFSPEC_MANIFEST"
236       - ta-builder-scm:
237           git-url: "{git-url}"
238           project: "ta/build-tools"
239           ref: "$SCM_REFSPEC_BUILD_TOOLS"
240       - ta-builder-scm:
241           git-url: "{git-url}"
242           project: "$SCM_PROJECT_TO_BUILD"
243           ref: "$SCM_PROJECT_TO_BUILD_REFSPEC"
244       - ta-builder-tox
245       - ta-builder-rpm:
246           # Just package some random project to verify "rpmbuilder" changes
247           project-to-build: "$SCM_PROJECT_TO_BUILD"
248
249 - builder:
250     name: ta-builder-job-merge
251     builders:
252       - ta-builder-scm:
253           git-url: "{git-url}"
254           project: "ta/manifest"
255           ref: "$SCM_REFSPEC_MANIFEST"
256       - ta-builder-scm:
257           git-url: "{git-url}"
258           project: "ta/build-tools"
259           ref: "$SCM_REFSPEC_BUILD_TOOLS"
260       - ta-builder-scm:
261           git-url: "{git-url}"
262           project: "ta/rpmbuilder"
263           ref: "$SCM_REFSPEC_RPMBUILDER"
264       - ta-builder-rpm:
265           project-to-build: "$GERRIT_PROJECT"
266       - ta-lf-infra-ship-rpms
267
268 - builder:
269     name: ta-builder-install-docker
270     builders:
271       - shell: !include-raw-escape: ../shell/ta-install-docker.sh
272
273 - builder:
274     name: ta-builder-install-build-tools
275     builders:
276       - shell: !include-raw-escape: ../shell/ta-install-build-tools.sh
277
278 ###########
279 # TRIGGER #
280 ###########
281
282 - trigger:
283     name: ta-trigger-job-verify
284     triggers:
285       - gerrit:
286           server-name: "{gerrit-server-name}"
287           trigger-on:
288             - patchset-created-event:
289                 exclude-drafts: "false"
290                 exclude-trivial-rebase: "false"
291                 exclude-no-code-change: "false"
292             - draft-published-event
293             - comment-added-contains-event:
294                 comment-contains-value: "recheck"
295             - comment-added-contains-event:
296                 comment-contains-value: "reverify"
297           projects:
298             - project-compare-type: "ANT"
299               project-pattern: "{project}"
300               branches:
301                 - branch-compare-type: "ANT"
302                   branch-pattern: "**/{branch}"
303           readable-message: true
304           skip-vote:
305             successful: "{gerrit-skip-vote}"
306             failed: "{gerrit-skip-vote}"
307             unstable: "{gerrit-skip-vote}"
308             notbuilt: "{gerrit-skip-vote}"
309
310 - trigger:
311     name: ta-trigger-job-merge
312     triggers:
313       - gerrit:
314           server-name: "{gerrit-server-name}"
315           trigger-on:
316             # Not sure if it would be better to use "change-merged" here and just clone the master
317             # branch. With the current approach the SCM can be identical in verify and merge jobs.
318             - ref-updated-event
319             - comment-added-contains-event:
320                 comment-contains-value: "remerge"
321           projects:
322             - project-compare-type: "ANT"
323               project-pattern: "{project}"
324               branches:
325                 - branch-compare-type: "ANT"
326                   branch-pattern: "**/{branch}"
327           readable-message: true
328
329 #############
330 # PUBLISHER #
331 #############
332
333 - publisher:
334     name: ta-publisher-job-verify
335     publishers:
336       - lf-infra-publish
337
338 - publisher:
339     name: ta-publisher-job-merge
340     publishers:
341       - lf-infra-publish
342       - ta-publisher-ci-build:
343           arch: "{arch}"
344       - trigger-parameterized-builds:
345           - project: "ta-ci-build-{arch}"
346             condition: UNSTABLE_OR_BETTER
347             trigger-with-no-params: true
348
349 - publisher:
350     name: ta-publisher-ci-build
351     publishers:
352       - lf-infra-publish
353       - email:
354           recipients: !j2: |
355             {%- if 'arm64' in arch -%}
356             armband@enea.com
357             {%- endif -%}