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