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