Global: Sent Slack notification when Jenkins job is back to normal.
[infra/cicd.git] / jjb / global / jjb-macros.yaml
1 ---
2 # these parameters are used for infra related variables
3 - parameter:
4     name: infra-parameters
5     parameters:
6       - string:
7           name: JJB_GIT_REPO
8           default: https://git.openstack.org/openstack-infra/jenkins-job-builder
9           description: OpenStack JJB repo
10       - string:
11           name: JJB_VERSION
12           default: 2.9.1
13           description: OpenStack JJB version to install - matches to LFN JJB version
14
15 # these parameters are used for setting the Gerrit Project on Nordix
16 - parameter:
17     name: project-parameters
18     parameters:
19       - string:
20           name: PROJECT
21           default: '{project}'
22           description: JJB configured PROJECT parameter to identify a Nordix Gerrit project
23       - string:
24           name: BRANCH
25           default: '{branch}'
26           description: "JJB configured BRANCH parameter (e.g. master, nordix-dev)"
27
28 # these parameters are used for streaming changes from various Gerrit Systems
29 - parameter:
30     name: nordix-gerrit-parameters
31     parameters:
32       - string:
33           name: GERRIT_USER
34           default: infra
35           description: Non-interactive user to stream Gerrit Events on Nordix Gerrit
36       - string:
37           name: GIT_BASE_HTTPS
38           default: https://gerrit.nordix.org
39           description: HTTPS URL of Project Repo on Nordix Gerrit to clone repo
40       - string:
41           name: GIT_BASE_SSH
42           default: ssh://$GERRIT_USER@gerrit.nordix.org:29418
43           description: HTTPS URL of Project Repo on Nordix Gerrit to clone repo
44
45 - parameter:
46     name: onap-gerrit-parameters
47     parameters:
48       - string:
49           name: GERRIT_USER
50           default: nordix
51           description: Non-interactive user to stream Gerrit Events on ONAP Gerrit
52       - string:
53           name: GIT_BASE_HTTPS
54           default: https://gerrit.onap.org/r/p
55           description: HTTPS URL to Project Repo on ONAP Gerrit to clone repo
56       - string:
57           name: GIT_BASE_SSH
58           default: ssh://$GERRIT_USER@gerrit.onap.org:29418
59           description: SSH URL to Project Repo on ONAP Gerrit to clone repo
60
61 - parameter:
62     name: acumos-gerrit-parameters
63     parameters:
64       - string:
65           name: GERRIT_USER
66           default: nordix
67           description: Non-interactive user to stream Gerrit Events on Acumos Gerrit
68       - string:
69           name: GIT_BASE_HTTPS
70           default: https://gerrit.acumos.org/r/p
71           description: HTTPS URL to Project Repo on Acumos Gerrit to clone repo
72       - string:
73           name: GIT_BASE_SSH
74           default: ssh://$GERRIT_USER@gerrit.acumos.org:29418
75           description: SSH URL to Project Repo on Acumos Gerrit to clone repo
76
77 - parameter:
78     name: odl-gerrit-parameters
79     parameters:
80       - string:
81           name: GERRIT_USER
82           default: nordix
83           description: Non-interactive user to stream Gerrit Events on ODL Gerrit
84       - string:
85           name: GIT_BASE_HTTPS
86           default: https://git.opendaylight.org/gerrit
87           description: HTTPS URL to Project Repo on OODL Gerrit to clone repo
88       - string:
89           name: GIT_BASE_SSH
90           default: ssh://$GERRIT_USER@git.opendaylight.org:29418
91           description: SSH URL to Project Repo on ODL Gerrit to clone repo
92
93 - parameter:
94     name: opendev-gerrit-parameters
95     parameters:
96       - string:
97           name: GERRIT_USER
98           default: nordix
99           description: Non-interactive user to stream Gerrit Events on OpenDev Gerrit
100       - string:
101           name: GIT_BASE_HTTPS
102           default: https://review.opendev.org
103           description: HTTPS URL to Project Repo on OpenDev Gerrit to clone repo
104       - string:
105           name: GIT_BASE_SSH
106           default: ssh://$GERRIT_USER@review.opendev.org:29418
107           description: SSH URL to Project Repo on OpenDev Gerrit to clone repo
108
109 # defaults for job build history
110 - property:
111     name: logrotate-default
112     properties:
113       - build-discarder:
114           days-to-keep: 60
115           num-to-keep: 200
116           artifact-days-to-keep: 60
117           artifact-num-to-keep: 200
118
119 # defaults for SCM and Gerrit
120 - scm:
121     name: git-scm
122     scm:
123       - git:
124           url: '$GIT_BASE_SSH/$PROJECT'
125           credentials-id: '{ssh-credentials-id}'
126           branches:
127             - 'refs/heads/{branch}'
128           refspec: '{refspec}'
129           timeout: 15
130           per-build-tag: false
131           skip-tag: true
132           shallow-clone: false
133           use-author: false
134           ignore-notify: false
135           wipe-workspace: '{wipe_workspace}'
136           prune: false
137           clean:
138             after: false
139             before: '{clean_before}'
140           choosing-strategy: 'default'
141
142 - scm:
143     name: git-scm-gerrit
144     scm:
145       - git:
146           url: '$GIT_BASE_SSH/$PROJECT'
147           credentials-id: '{ssh-credentials-id}'
148           branches:
149             - 'refs/heads/{branch}'
150           refspec: '{refspec}'
151           timeout: 15
152           per-build-tag: false
153           skip-tag: true
154           shallow-clone: false
155           use-author: false
156           ignore-notify: false
157           wipe-workspace: '{wipe_workspace}'
158           prune: false
159           clean:
160             after: false
161             before: '{clean_before}'
162           choosing-strategy: 'gerrit'
163
164 # triggers for Nordix Gerrit
165 - trigger:
166     name: nordix-gerrit-trigger-patchset-created
167     triggers:
168       - gerrit:
169           server-name: 'Nordix Gerrit'
170           trigger-on:
171             - patchset-created-event:
172                 exclude-drafts: 'false'
173                 exclude-trivial-rebase: 'false'
174                 exclude-no-code-change: 'false'
175             - draft-published-event
176             - comment-added-contains-event:
177                 comment-contains-value: 'recheck'
178             - comment-added-contains-event:
179                 comment-contains-value: 'reverify'
180           projects:
181             - project-compare-type: 'REG_EXP'
182               project-pattern: '{project}'
183               branches:
184                 - branch-compare-type: 'ANT'
185                   branch-pattern: '**/{branch}'
186               file-paths:
187                 - compare-type: 'ANT'
188                   pattern: '{files}'
189           skip-vote:
190             successful: false
191             failed: false
192             unstable: false
193             notbuilt: false
194
195 - trigger:
196     name: nordix-gerrit-trigger-change-merged
197     triggers:
198       - gerrit:
199           server-name: 'Nordix Gerrit'
200           trigger-on:
201             - change-merged-event
202             - comment-added-contains-event:
203                 comment-contains-value: 'remerge'
204           projects:
205             - project-compare-type: 'ANT'
206               project-pattern: '{project}'
207               branches:
208                 - branch-compare-type: 'ANT'
209                   branch-pattern: '**/{branch}'
210               file-paths:
211                 - compare-type: 'ANT'
212                   pattern: '{files}'
213
214 - trigger:
215     name: nordix-gerrit-push-upstream
216     triggers:
217       - gerrit:
218           server-name: 'Nordix Gerrit'
219           trigger-on:
220             - comment-added-contains-event:
221                 comment-contains-value: 'push-upstream'
222           projects:
223             - project-compare-type: 'ANT'
224               project-pattern: '{project}'
225               branches:
226                 - branch-compare-type: 'ANT'
227                   branch-pattern: '**/{branch}'
228               file-paths:
229                 - compare-type: 'ANT'
230                   pattern: '{files}'
231
232 - trigger:
233     name: nordix-gerrit-patchset-created-or-push-upstream
234     triggers:
235       - gerrit:
236           server-name: 'Nordix Gerrit'
237           trigger-on:
238             - comment-added-contains-event:
239                 comment-contains-value: 'push-upstream'
240             - patchset-created-event:
241                 exclude-drafts: true
242           projects:
243             - project-compare-type: 'ANT'
244               project-pattern: '{project}'
245               branches:
246                 - branch-compare-type: 'ANT'
247                   branch-pattern: '**/{branch}'
248               file-paths:
249                 - compare-type: 'ANT'
250                   pattern: '{files}'
251
252 # triggers for ONAP Gerrit
253 - trigger:
254     name: onap-gerrit-trigger-change-merged
255     triggers:
256       - gerrit:
257           server-name: 'ONAP Gerrit'
258           trigger-on:
259             - change-merged-event
260             - comment-added-contains-event:
261                 comment-contains-value: 'remerge'
262           projects:
263             - project-compare-type: 'ANT'
264               project-pattern: '{project}'
265               branches:
266                 - branch-compare-type: 'ANT'
267                   branch-pattern: '**/{branch}'
268               file-paths:
269                 - compare-type: 'ANT'
270                   pattern: '{files}'
271           silent: true
272           silent-start: true
273
274 # triggers for Acumos Gerrit
275 - trigger:
276     name: acumos-gerrit-trigger-change-merged
277     triggers:
278       - gerrit:
279           server-name: 'Acumos Gerrit'
280           trigger-on:
281             - change-merged-event
282             - comment-added-contains-event:
283                 comment-contains-value: 'remerge'
284           projects:
285             - project-compare-type: 'ANT'
286               project-pattern: '{project}'
287               branches:
288                 - branch-compare-type: 'ANT'
289                   branch-pattern: '**/{branch}'
290               file-paths:
291                 - compare-type: 'ANT'
292                   pattern: '{files}'
293           silent: true
294           silent-start: true
295
296 # triggers for ODL Gerrit
297 - trigger:
298     name: odl-gerrit-trigger-change-merged
299     triggers:
300       - gerrit:
301           server-name: 'ODL Gerrit'
302           trigger-on:
303             - change-merged-event
304             - comment-added-contains-event:
305                 comment-contains-value: 'remerge'
306           projects:
307             - project-compare-type: 'ANT'
308               project-pattern: '{project}'
309               branches:
310                 - branch-compare-type: 'ANT'
311                   branch-pattern: '**/{branch}'
312               file-paths:
313                 - compare-type: 'ANT'
314                   pattern: '{files}'
315           silent: true
316           silent-start: true
317
318 # triggers for OpenDev Gerrit
319 - trigger:
320     name: opendev-gerrit-trigger-change-merged
321     triggers:
322       - gerrit:
323           server-name: 'OpenDev Gerrit'
324           trigger-on:
325             - change-merged-event
326             - comment-added-contains-event:
327                 comment-contains-value: 'remerge'
328           projects:
329             - project-compare-type: 'ANT'
330               project-pattern: '{project}'
331               branches:
332                 - branch-compare-type: 'ANT'
333                   branch-pattern: '**/{branch}'
334               file-paths:
335                 - compare-type: 'ANT'
336                   pattern: '{files}'
337           silent: true
338           silent-start: true
339
340 # wrappers to use for jobs
341 - wrapper:
342     name: nordixinfra-jjb-creds-wrapper
343     wrappers:
344       - credentials-binding:
345           - username-password-separated:
346               credential-id: nordixinfra-jjb-creds
347               username: JJB_USERNAME
348               password: JJB_USERTOKEN
349
350 # timeout wrapper to use for jobs
351 - wrapper:
352     name: build-timeout
353     wrappers:
354       - timeout:
355           timeout: '{timeout}'
356           timeout-var: 'BUILD_TIMEOUT'
357           fail: true
358
359 # wrapper to fix jenkins build workspace permissions
360 - wrapper:
361     name: fix-workspace-permissions
362     wrappers:
363       - pre-scm-buildstep:
364           failOnError: true
365           buildsteps:
366             - shell: |
367                 #!/bin/bash
368                 sudo chown -R $USER:$USER $WORKSPACE || exit 1
369
370 - publisher:
371     name: notify-slack
372     publishers:
373       - slack:
374           room: '{slack-channel}'
375           notify-failure: True
376           notify-backtonormal: True
377
378 # property to discard old builds
379 - property:
380     name: logrotate
381     properties:
382       - build-discarder:
383           days-to-keep: 30
384           num-to-keep: 100
385           artifact-days-to-keep: 30
386           artifact-num-to-keep: 100