Merge changes from topic 'add-odl-gerrit'
[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 # defaults for job build history
94 - property:
95     name: logrotate-default
96     properties:
97       - build-discarder:
98           days-to-keep: 60
99           num-to-keep: 200
100           artifact-days-to-keep: 60
101           artifact-num-to-keep: 200
102
103 # defaults for SCM and Gerrit
104 - scm:
105     name: git-scm
106     scm:
107       - git:
108           url: '$GIT_BASE_SSH/$PROJECT'
109           credentials-id: '{ssh-credentials-id}'
110           branches:
111             - 'refs/heads/{branch}'
112           refspec: '{refspec}'
113           timeout: 15
114           per-build-tag: false
115           skip-tag: true
116           shallow-clone: false
117           use-author: false
118           ignore-notify: false
119           wipe-workspace: true
120           prune: false
121           choosing-strategy: 'default'
122
123 - scm:
124     name: git-scm-gerrit
125     scm:
126       - git:
127           url: '$GIT_BASE_SSH/$PROJECT'
128           credentials-id: '{ssh-credentials-id}'
129           branches:
130             - 'refs/heads/{branch}'
131           refspec: '{refspec}'
132           timeout: 15
133           per-build-tag: false
134           skip-tag: true
135           shallow-clone: false
136           use-author: false
137           ignore-notify: false
138           wipe-workspace: true
139           prune: false
140           choosing-strategy: 'gerrit'
141
142 # triggers for Nordix Gerrit
143 - trigger:
144     name: nordix-gerrit-trigger-patchset-created
145     triggers:
146       - gerrit:
147           server-name: 'Nordix Gerrit'
148           trigger-on:
149             - patchset-created-event:
150                 exclude-drafts: 'false'
151                 exclude-trivial-rebase: 'false'
152                 exclude-no-code-change: 'false'
153             - draft-published-event
154             - comment-added-contains-event:
155                 comment-contains-value: 'recheck'
156             - comment-added-contains-event:
157                 comment-contains-value: 'reverify'
158           projects:
159             - project-compare-type: 'REG_EXP'
160               project-pattern: '{project}'
161               branches:
162                 - branch-compare-type: 'ANT'
163                   branch-pattern: '**/{branch}'
164               file-paths:
165                 - compare-type: 'ANT'
166                   pattern: '{files}'
167
168 - trigger:
169     name: nordix-gerrit-trigger-change-merged
170     triggers:
171       - gerrit:
172           server-name: 'Nordix Gerrit'
173           trigger-on:
174             - change-merged-event
175             - comment-added-contains-event:
176                 comment-contains-value: 'remerge'
177           projects:
178             - project-compare-type: 'ANT'
179               project-pattern: '{project}'
180               branches:
181                 - branch-compare-type: 'ANT'
182                   branch-pattern: '**/{branch}'
183               file-paths:
184                 - compare-type: 'ANT'
185                   pattern: '{files}'
186
187 - trigger:
188     name: nordix-gerrit-push-upstream
189     triggers:
190       - gerrit:
191           server-name: 'Nordix Gerrit'
192           trigger-on:
193             - comment-added-contains-event:
194                 comment-contains-value: 'push-upstream'
195           projects:
196             - project-compare-type: 'ANT'
197               project-pattern: '{project}'
198               branches:
199                 - branch-compare-type: 'ANT'
200                   branch-pattern: '**/{branch}'
201               file-paths:
202                 - compare-type: 'ANT'
203                   pattern: '{files}'
204
205 # triggers for ONAP Gerrit
206 - trigger:
207     name: onap-gerrit-trigger-change-merged
208     triggers:
209       - gerrit:
210           server-name: 'ONAP Gerrit'
211           trigger-on:
212             - change-merged-event
213             - comment-added-contains-event:
214                 comment-contains-value: 'remerge'
215           projects:
216             - project-compare-type: 'ANT'
217               project-pattern: '{project}'
218               branches:
219                 - branch-compare-type: 'ANT'
220                   branch-pattern: '**/{branch}'
221               file-paths:
222                 - compare-type: 'ANT'
223                   pattern: '{files}'
224           silent: true
225           silent-start: true
226
227 # triggers for Acumos Gerrit
228 - trigger:
229     name: acumos-gerrit-trigger-change-merged
230     triggers:
231       - gerrit:
232           server-name: 'Acumos Gerrit'
233           trigger-on:
234             - change-merged-event
235             - comment-added-contains-event:
236                 comment-contains-value: 'remerge'
237           projects:
238             - project-compare-type: 'ANT'
239               project-pattern: '{project}'
240               branches:
241                 - branch-compare-type: 'ANT'
242                   branch-pattern: '**/{branch}'
243               file-paths:
244                 - compare-type: 'ANT'
245                   pattern: '{files}'
246           silent: true
247           silent-start: true
248
249 # triggers for ODL Gerrit
250 - trigger:
251     name: odl-gerrit-trigger-change-merged
252     triggers:
253       - gerrit:
254           server-name: 'ODL Gerrit'
255           trigger-on:
256             - change-merged-event
257             - comment-added-contains-event:
258                 comment-contains-value: 'remerge'
259           projects:
260             - project-compare-type: 'ANT'
261               project-pattern: '{project}'
262               branches:
263                 - branch-compare-type: 'ANT'
264                   branch-pattern: '**/{branch}'
265               file-paths:
266                 - compare-type: 'ANT'
267                   pattern: '{files}'
268           silent: true
269           silent-start: true
270
271 # wrappers to use for jobs
272 - wrapper:
273     name: nordixinfra-jjb-creds-wrapper
274     wrappers:
275       - credentials-binding:
276           - username-password-separated:
277               credential-id: nordixinfra-jjb-creds
278               username: JJB_USERNAME
279               password: JJB_USERTOKEN
280
281 # timeout wrapper to use for jobs
282 - wrapper:
283     name: build-timeout
284     wrappers:
285       - timeout:
286           timeout: '{timeout}'
287           timeout-var: 'BUILD_TIMEOUT'
288           fail: true
289
290 # wrapper to fix jenkins build workspace permissions
291 - wrapper:
292     name: fix-workspace-permissions
293     wrappers:
294       - pre-scm-buildstep:
295           failOnError: true
296           buildsteps:
297             - shell: |
298                 #!/bin/bash
299                 sudo chown -R $USER:$USER $WORKSPACE || exit 1
300
301 - publisher:
302     name: notify-slack
303     publishers:
304       - slack:
305           room: '{slack-channel}'
306           notify-failure: True
307
308 # property to discard old builds
309 - property:
310     name: logrotate
311     properties:
312       - build-discarder:
313           days-to-keep: 30
314           num-to-keep: 100
315           artifact-days-to-keep: 30
316           artifact-num-to-keep: 100