OpenDev: Introducing OpenDev to Nordix
[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 # triggers for ONAP Gerrit
227 - trigger:
228     name: onap-gerrit-trigger-change-merged
229     triggers:
230       - gerrit:
231           server-name: 'ONAP Gerrit'
232           trigger-on:
233             - change-merged-event
234             - comment-added-contains-event:
235                 comment-contains-value: 'remerge'
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           silent: true
246           silent-start: true
247
248 # triggers for Acumos Gerrit
249 - trigger:
250     name: acumos-gerrit-trigger-change-merged
251     triggers:
252       - gerrit:
253           server-name: 'Acumos Gerrit'
254           trigger-on:
255             - change-merged-event
256             - comment-added-contains-event:
257                 comment-contains-value: 'remerge'
258           projects:
259             - project-compare-type: 'ANT'
260               project-pattern: '{project}'
261               branches:
262                 - branch-compare-type: 'ANT'
263                   branch-pattern: '**/{branch}'
264               file-paths:
265                 - compare-type: 'ANT'
266                   pattern: '{files}'
267           silent: true
268           silent-start: true
269
270 # triggers for ODL Gerrit
271 - trigger:
272     name: odl-gerrit-trigger-change-merged
273     triggers:
274       - gerrit:
275           server-name: 'ODL Gerrit'
276           trigger-on:
277             - change-merged-event
278             - comment-added-contains-event:
279                 comment-contains-value: 'remerge'
280           projects:
281             - project-compare-type: 'ANT'
282               project-pattern: '{project}'
283               branches:
284                 - branch-compare-type: 'ANT'
285                   branch-pattern: '**/{branch}'
286               file-paths:
287                 - compare-type: 'ANT'
288                   pattern: '{files}'
289           silent: true
290           silent-start: true
291
292 # triggers for OpenDev Gerrit
293 - trigger:
294     name: opendev-gerrit-trigger-change-merged
295     triggers:
296       - gerrit:
297           server-name: 'OpenDev Gerrit'
298           trigger-on:
299             - change-merged-event
300             - comment-added-contains-event:
301                 comment-contains-value: 'remerge'
302           projects:
303             - project-compare-type: 'ANT'
304               project-pattern: '{project}'
305               branches:
306                 - branch-compare-type: 'ANT'
307                   branch-pattern: '**/{branch}'
308               file-paths:
309                 - compare-type: 'ANT'
310                   pattern: '{files}'
311           silent: true
312           silent-start: true
313
314 # wrappers to use for jobs
315 - wrapper:
316     name: nordixinfra-jjb-creds-wrapper
317     wrappers:
318       - credentials-binding:
319           - username-password-separated:
320               credential-id: nordixinfra-jjb-creds
321               username: JJB_USERNAME
322               password: JJB_USERTOKEN
323
324 # timeout wrapper to use for jobs
325 - wrapper:
326     name: build-timeout
327     wrappers:
328       - timeout:
329           timeout: '{timeout}'
330           timeout-var: 'BUILD_TIMEOUT'
331           fail: true
332
333 # wrapper to fix jenkins build workspace permissions
334 - wrapper:
335     name: fix-workspace-permissions
336     wrappers:
337       - pre-scm-buildstep:
338           failOnError: true
339           buildsteps:
340             - shell: |
341                 #!/bin/bash
342                 sudo chown -R $USER:$USER $WORKSPACE || exit 1
343
344 - publisher:
345     name: notify-slack
346     publishers:
347       - slack:
348           room: '{slack-channel}'
349           notify-failure: True
350
351 # property to discard old builds
352 - property:
353     name: logrotate
354     properties:
355       - build-discarder:
356           days-to-keep: 30
357           num-to-keep: 100
358           artifact-days-to-keep: 30
359           artifact-num-to-keep: 100