OPENDEV: Add patchset-created trigger for push upstream jenkins job.
[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: true
136           prune: false
137           choosing-strategy: 'default'
138
139 - scm:
140     name: git-scm-gerrit
141     scm:
142       - git:
143           url: '$GIT_BASE_SSH/$PROJECT'
144           credentials-id: '{ssh-credentials-id}'
145           branches:
146             - 'refs/heads/{branch}'
147           refspec: '{refspec}'
148           timeout: 15
149           per-build-tag: false
150           skip-tag: true
151           shallow-clone: false
152           use-author: false
153           ignore-notify: false
154           wipe-workspace: true
155           prune: false
156           choosing-strategy: 'gerrit'
157
158 # triggers for Nordix Gerrit
159 - trigger:
160     name: nordix-gerrit-trigger-patchset-created
161     triggers:
162       - gerrit:
163           server-name: 'Nordix Gerrit'
164           trigger-on:
165             - patchset-created-event:
166                 exclude-drafts: 'false'
167                 exclude-trivial-rebase: 'false'
168                 exclude-no-code-change: 'false'
169             - draft-published-event
170             - comment-added-contains-event:
171                 comment-contains-value: 'recheck'
172             - comment-added-contains-event:
173                 comment-contains-value: 'reverify'
174           projects:
175             - project-compare-type: 'REG_EXP'
176               project-pattern: '{project}'
177               branches:
178                 - branch-compare-type: 'ANT'
179                   branch-pattern: '**/{branch}'
180               file-paths:
181                 - compare-type: 'ANT'
182                   pattern: '{files}'
183           skip-vote:
184             successful: false
185             failed: false
186             unstable: false
187             notbuilt: false
188
189 - trigger:
190     name: nordix-gerrit-trigger-change-merged
191     triggers:
192       - gerrit:
193           server-name: 'Nordix Gerrit'
194           trigger-on:
195             - change-merged-event
196             - comment-added-contains-event:
197                 comment-contains-value: 'remerge'
198           projects:
199             - project-compare-type: 'ANT'
200               project-pattern: '{project}'
201               branches:
202                 - branch-compare-type: 'ANT'
203                   branch-pattern: '**/{branch}'
204               file-paths:
205                 - compare-type: 'ANT'
206                   pattern: '{files}'
207
208 - trigger:
209     name: nordix-gerrit-push-upstream
210     triggers:
211       - gerrit:
212           server-name: 'Nordix Gerrit'
213           trigger-on:
214             - comment-added-contains-event:
215                 comment-contains-value: 'push-upstream'
216           projects:
217             - project-compare-type: 'ANT'
218               project-pattern: '{project}'
219               branches:
220                 - branch-compare-type: 'ANT'
221                   branch-pattern: '**/{branch}'
222               file-paths:
223                 - compare-type: 'ANT'
224                   pattern: '{files}'
225
226 - trigger:
227     name: nordix-gerrit-patchset-created-or-push-upstream
228     triggers:
229       - gerrit:
230           server-name: 'Nordix Gerrit'
231           trigger-on:
232             - comment-added-contains-event:
233                 comment-contains-value: 'push-upstream'
234             - patchset-created-event:
235                 exclude-drafts: true
236           projects:
237             - project-compare-type: 'ANT'
238               project-pattern: '{project}'
239               branches:
240                 - branch-compare-type: 'ANT'
241                   branch-pattern: '**/{branch}'
242               file-paths:
243                 - compare-type: 'ANT'
244                   pattern: '{files}'
245
246 # triggers for ONAP Gerrit
247 - trigger:
248     name: onap-gerrit-trigger-change-merged
249     triggers:
250       - gerrit:
251           server-name: 'ONAP Gerrit'
252           trigger-on:
253             - change-merged-event
254             - comment-added-contains-event:
255                 comment-contains-value: 'remerge'
256           projects:
257             - project-compare-type: 'ANT'
258               project-pattern: '{project}'
259               branches:
260                 - branch-compare-type: 'ANT'
261                   branch-pattern: '**/{branch}'
262               file-paths:
263                 - compare-type: 'ANT'
264                   pattern: '{files}'
265           silent: true
266           silent-start: true
267
268 # triggers for Acumos Gerrit
269 - trigger:
270     name: acumos-gerrit-trigger-change-merged
271     triggers:
272       - gerrit:
273           server-name: 'Acumos Gerrit'
274           trigger-on:
275             - change-merged-event
276             - comment-added-contains-event:
277                 comment-contains-value: 'remerge'
278           projects:
279             - project-compare-type: 'ANT'
280               project-pattern: '{project}'
281               branches:
282                 - branch-compare-type: 'ANT'
283                   branch-pattern: '**/{branch}'
284               file-paths:
285                 - compare-type: 'ANT'
286                   pattern: '{files}'
287           silent: true
288           silent-start: true
289
290 # triggers for ODL Gerrit
291 - trigger:
292     name: odl-gerrit-trigger-change-merged
293     triggers:
294       - gerrit:
295           server-name: 'ODL Gerrit'
296           trigger-on:
297             - change-merged-event
298             - comment-added-contains-event:
299                 comment-contains-value: 'remerge'
300           projects:
301             - project-compare-type: 'ANT'
302               project-pattern: '{project}'
303               branches:
304                 - branch-compare-type: 'ANT'
305                   branch-pattern: '**/{branch}'
306               file-paths:
307                 - compare-type: 'ANT'
308                   pattern: '{files}'
309           silent: true
310           silent-start: true
311
312 # triggers for OpenDev Gerrit
313 - trigger:
314     name: opendev-gerrit-trigger-change-merged
315     triggers:
316       - gerrit:
317           server-name: 'OpenDev Gerrit'
318           trigger-on:
319             - change-merged-event
320             - comment-added-contains-event:
321                 comment-contains-value: 'remerge'
322           projects:
323             - project-compare-type: 'ANT'
324               project-pattern: '{project}'
325               branches:
326                 - branch-compare-type: 'ANT'
327                   branch-pattern: '**/{branch}'
328               file-paths:
329                 - compare-type: 'ANT'
330                   pattern: '{files}'
331           silent: true
332           silent-start: true
333
334 # wrappers to use for jobs
335 - wrapper:
336     name: nordixinfra-jjb-creds-wrapper
337     wrappers:
338       - credentials-binding:
339           - username-password-separated:
340               credential-id: nordixinfra-jjb-creds
341               username: JJB_USERNAME
342               password: JJB_USERTOKEN
343
344 # timeout wrapper to use for jobs
345 - wrapper:
346     name: build-timeout
347     wrappers:
348       - timeout:
349           timeout: '{timeout}'
350           timeout-var: 'BUILD_TIMEOUT'
351           fail: true
352
353 # wrapper to fix jenkins build workspace permissions
354 - wrapper:
355     name: fix-workspace-permissions
356     wrappers:
357       - pre-scm-buildstep:
358           failOnError: true
359           buildsteps:
360             - shell: |
361                 #!/bin/bash
362                 sudo chown -R $USER:$USER $WORKSPACE || exit 1
363
364 - publisher:
365     name: notify-slack
366     publishers:
367       - slack:
368           room: '{slack-channel}'
369           notify-failure: True
370
371 # property to discard old builds
372 - property:
373     name: logrotate
374     properties:
375       - build-discarder:
376           days-to-keep: 30
377           num-to-keep: 100
378           artifact-days-to-keep: 30
379           artifact-num-to-keep: 100