blob: 39517ab365506ee2273b29a2297247f4fe4c0367 [file] [log] [blame]
Zack Williams7468c362018-04-06 09:52:30 -07001---
2# CORD JJB macros
3
4# control how long builds and artifact are retained
5- property:
6 name: cord-infra-properties
7 properties:
8 - build-discarder:
9 days-to-keep: '{build-days-to-keep}'
10 artifact-num-to-keep: '{artifact-num-to-keep}'
11
12# checkout entire source tree with repo
13# docs: https://docs.openstack.org/infra/jenkins-job-builder/scm.html#scm.repo
14- scm:
15 name: cord-infra-gerrit-repo-scm
16 scm:
17 - repo:
Zack Williamsc27ca2d2018-04-11 13:16:45 -070018 manifest-url: '{manifest-url}'
Zack Williams7468c362018-04-06 09:52:30 -070019 manifest-branch: '{branch}'
20 destination-dir: '{destination-dir}'
21 jobs: 4
22 reset-first: true
23 depth: 1
24
Zack Williams15a31c82018-08-29 15:10:03 -070025# same as lf-infra-gerrit-scm, but allows checkouts to a subdir of $WORKSPACE
26# with the `basedir` option
27#
28# `basedir` serves the same function as `destination-dir` in the repo scm
29# macros, seems strange that they're named differently.
30- scm:
31 name: cord-infra-gerrit-scm
32 scm:
33 - git:
34 credentials-id: '{jenkins-ssh-credential}'
35 url: '{git-url}'
36 refspec: '{refspec}'
37 branches:
38 - 'refs/heads/{branch}'
39 skip-tag: true
40 wipe-workspace: true
41 submodule:
42 recursive: '{submodule-recursive}'
43 choosing-strategy: '{choosing-strategy}'
44 basedir: '{basedir}'
45
Zack Williams7468c362018-04-06 09:52:30 -070046# trigger on gerrit patchsets and actions
47# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit
48- trigger:
49 name: cord-infra-gerrit-trigger-patchset
50 triggers:
Zack Williamse64341b2018-04-10 22:14:35 -070051 - gerrit:
52 server-name: '{gerrit-server-name}'
53 dependency-jobs: '{dependency-jobs}'
54 silent-start: true
55 trigger-on:
56 - patchset-created-event:
57 exclude-drafts: true
58 exclude-trivial-rebase: false
59 exclude-no-code-change: true
60 - draft-published-event
61 - comment-added-contains-event:
62 comment-contains-value: '(?i)^.*recheck$'
63 projects:
64 - project-compare-type: REG_EXP
65 project-pattern: '{project-regexp}'
66 branches:
67 - branch-compare-type: REG_EXP
68 branch-pattern: '{branch-regexp}'
Zack Williamsc27ca2d2018-04-11 13:16:45 -070069 file-paths:
70 - compare-type: REG_EXP
71 pattern: '{file-include-regexp}'
Zack Williams7468c362018-04-06 09:52:30 -070072
73# trigger on gerrit commits/merges
74- trigger:
75 name: cord-infra-gerrit-trigger-merge
76 triggers:
Zack Williamse64341b2018-04-10 22:14:35 -070077 - gerrit:
78 server-name: '{gerrit-server-name}'
79 dependency-jobs: '{dependency-jobs}'
Zack Williams9ac51db2018-04-16 16:44:24 -070080 silent-start: true
Zack Williamse64341b2018-04-10 22:14:35 -070081 trigger-on:
82 - change-merged-event
83 projects:
84 - project-compare-type: REG_EXP
85 project-pattern: '{project-regexp}'
86 branches:
87 - branch-compare-type: REG_EXP
88 branch-pattern: '{branch-regexp}'
Zack Williamsc27ca2d2018-04-11 13:16:45 -070089 file-paths:
90 - compare-type: REG_EXP
91 pattern: '{file-include-regexp}'
Zack Williams5aa37e12019-02-13 13:28:29 -070092
Zack Williams5d81f812019-02-27 14:37:09 -070093# Trigger on GitHub pull requests
94# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.github-pull-request
95# Uses the standard 'ok to test', etc. commands per the plugin:
96# https://github.com/jenkinsci/ghprb-plugin
Zack Williams73c3cf42019-02-25 23:43:22 -070097- trigger:
Zack Williams5d81f812019-02-27 14:37:09 -070098 name: cord-infra-github-pr-trigger
Zack Williams73c3cf42019-02-25 23:43:22 -070099 triggers:
100 - github-pull-request:
Zack Williams5d81f812019-02-27 14:37:09 -0700101 auth-id: '{github_pr_auth_id}'
102 github-hooks: true # Create github hooks automatically
103 cancel-builds-on-update: true
104 auto-close-on-fail: false
Zack Williams4b5722e2019-02-27 15:14:04 -0700105 only-trigger-phrase: false
Jeremy Ronquillo9adc0a92020-01-29 10:49:45 -0800106 status-context: '{status_context}' # Name of testing system in PR
Zack Williams5d81f812019-02-27 14:37:09 -0700107 permit-all: false # don't trigger on every PR
108 org-list: '{obj:github_pr_org_list}'
109 allow-whitelist-orgs-as-admins: true
Zack Williams73c3cf42019-02-25 23:43:22 -0700110
You Wangfd869052020-03-13 11:23:11 -0700111# Trigger on GitHub PR merge
112# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.generic-webhook-trigger
113- trigger:
114 name: cord-infra-github-pr-trigger-merge
115 triggers:
116 - generic-webhook-trigger:
117 post-content-params:
118 - type: JSONPath
119 key: action
120 value: $.action
121 - type: JSONPath
122 key: merged
123 value: $.pull_request.merged
You Wang4487d012020-03-30 11:09:48 -0700124 - type: JSONPath
You Wang5c15a7a2020-04-02 11:24:33 -0700125 key: repoUrl
126 value: $.pull_request.base.repo.html_url
127 - type: JSONPath
128 key: repoName
129 value: $.pull_request.base.repo.name
130 - type: JSONPath
You Wang4487d012020-03-30 11:09:48 -0700131 key: branchName
132 value: $.pull_request.base.ref
133 - type: JSONPath
You Wang5c15a7a2020-04-02 11:24:33 -0700134 key: commitHash
135 value: $.pull_request.merge_commit_sha
You Wangfd869052020-03-13 11:23:11 -0700136 regex-filter-text: $action,$merged
137 regex-filter-expression: ^(closed,true)$
138 cause: Generic Cause
139 token: '{project}'
140
Zack Williams5aa37e12019-02-13 13:28:29 -0700141# wrapper to provide pypi config file
142
143- wrapper:
144 name: cord-pypi-wrapper
145 wrappers:
146 - mask-passwords
147 - timeout:
148 type: absolute
149 timeout: '{build-timeout}'
150 timeout-var: 'BUILD_TIMEOUT'
151 fail: true
152 - timestamps
153 - ssh-agent-credentials:
154 users:
155 - '{jenkins-ssh-credential}'
156 - config-file-provider:
157 files:
158 - file-id: pypirc
159 target: '$HOME/.pypirc'
160 - file-id: pipconf
161 target: '$HOME/.config/pip/pip.conf'
Zack Williams73c3cf42019-02-25 23:43:22 -0700162
Carmelo Casconebaceafe2021-01-10 19:28:49 -0800163
Zack Williams5f257162022-07-25 14:22:29 -0700164
Zack Williamsbe542312022-06-23 21:51:32 -0700165
166################## NEW and CONVERGED MACROS ###################
167# Name matches macro in ONOS/Aether JJB, for future unification
168
169# control how long builds and artifact are retained
170# differs from lf-infra-properties as it retains artifacts
171- property:
172 name: onf-infra-properties
173 properties:
174 - build-discarder:
175 days-to-keep: '{build-days-to-keep}'
176 artifact-num-to-keep: '{artifact-num-to-keep}'
177
Zack Williams5f257162022-07-25 14:22:29 -0700178# Permissions specific to VOLTHA jobs
179# JJB supports this, but not the GROUP annotation which causes warnings
180# https://jenkins-job-builder.readthedocs.io/en/latest/properties.html?highlight=matrix#properties.authorization
181- property:
182 name: onf-infra-volthadevs-permissions
183 properties:
184 - raw:
185 xml: |
186 <hudson.security.AuthorizationMatrixProperty>
187 <inheritanceStrategy class="org.jenkinsci.plugins.matrixauth.inheritance.InheritParentStrategy"/>
188 <permission>GROUP:hudson.model.Item.Build:VOLTHADevs</permission>
189 <permission>GROUP:hudson.model.Item.Cancel:VOLTHADevs</permission>
190 <permission>GROUP:hudson.model.Item.Configure:VOLTHADevs</permission>
191 <permission>GROUP:hudson.model.Item.Discover:VOLTHADevs</permission>
192 <permission>GROUP:hudson.model.Item.ExtendedRead:VOLTHADevs</permission>
193 <permission>GROUP:hudson.model.Item.Read:VOLTHADevs</permission>
194 <permission>GROUP:hudson.model.Item.Workspace:VOLTHADevs</permission>
195 <permission>GROUP:hudson.model.Run.Replay:VOLTHADevs</permission>
196 <permission>GROUP:hudson.model.Run.Update:VOLTHADevs</permission>
197 </hudson.security.AuthorizationMatrixProperty>
198
Zack Williamsbe542312022-06-23 21:51:32 -0700199# wrapper to provide SSH key and fill in ~/.ssh/known_hosts file for use with rsync
200- wrapper:
201 name: onf-infra-rsync-wrappers
202 wrappers:
203 - mask-passwords
204 - timeout:
205 type: absolute
206 timeout: '{build-timeout}'
207 timeout-var: 'BUILD_TIMEOUT'
208 fail: true
209 - timestamps
210 - ssh-agent-credentials:
211 users: '{obj:ssh_credential_list}'
212 - config-file-provider:
213 files:
214 - file-id: known_hosts
215 target: '$HOME/.ssh/known_hosts'
216
217# trigger on gerrit patchsets and actions
218# docs: https://docs.openstack.org/infra/jenkins-job-builder/triggers.html#triggers.gerrit
219# Uses a regex based project match
220- trigger:
221 name: onf-infra-gerrit-trigger-patchset
222 triggers:
223 - gerrit:
224 server-name: '{gerrit-server-name}'
225 dependency-jobs: '{dependency-jobs}'
226 silent-start: true
227 trigger-on:
228 - patchset-created-event:
229 exclude-drafts: true
230 exclude-trivial-rebase: false
231 exclude-no-code-change: false
232 - draft-published-event
233 - comment-added-contains-event:
234 comment-contains-value: '(?i)^.*recheck$'
235 projects:
236 - project-compare-type: REG_EXP
237 project-pattern: '{project-regexp}'
238 branches:
239 - branch-compare-type: REG_EXP
240 branch-pattern: '{branch-regexp}'
241 file-paths:
242 - compare-type: REG_EXP
243 pattern: '{file-include-regexp}'
244
245# trigger for gerrit patch submission
246- trigger:
247 name: onf-infra-gerrit-trigger-merge
248 triggers:
249 - gerrit:
250 server-name: '{gerrit-server-name}'
251 dependency-jobs: '{dependency-jobs}'
252 silent-start: true
253 trigger-on:
254 - change-merged-event
255 projects:
256 - project-compare-type: REG_EXP
257 project-pattern: '{project-regexp}'
258 branches:
259 - branch-compare-type: REG_EXP
260 branch-pattern: '{branch-regexp}'
261 file-paths:
262 - compare-type: REG_EXP
263 pattern: '{file-include-regexp}'
264
265# same as lf-infra-*-scm, but allows checkouts to a subdir of $WORKSPACE
266# with the `basedir` option
267#
268# `basedir` is used as `destination-dir` for the repo scm macros for
269# consistency
270
271- scm:
272 name: onf-infra-gerrit-scm
273 scm:
274 - git:
275 credentials-id: '{jenkins-ssh-credential}'
276 url: '{git-url}'
277 refspec: '{refspec}'
278 branches:
279 - 'refs/heads/{branch}'
280 wipe-workspace: true
281 submodule:
282 disable: '{submodule-disable}'
283 recursive: '{submodule-recursive}'
284 timeout: '{submodule-timeout}'
285 choosing-strategy: '{choosing-strategy}'
286 basedir: '{basedir}'
287
288- scm:
289 name: onf-infra-gerrit-repo-scm
290 scm:
291 - repo:
292 manifest-url: '{manifest-url}'
293 manifest-branch: '{branch}'
294 destination-dir: '{basedir}'
295 jobs: 4
296 reset-first: true
297 depth: 1
298
299# download a specific patchset after checking out entire source tree with repo
300# docs: https://docs.openstack.org/infra/jenkins-job-builder/builders.html#builders.inject
301- builder:
302 name: onf-infra-gerrit-repo-patch
303 builders:
304 - inject:
305 properties-content: |
306 BASEDIR={basedir}
307 GERRIT_PROJECT={project}
308 GERRIT_CHANGE_NUMBER={change-number}
309 GERRIT_PATCHSET_NUMBER={patchset-number}
310 - shell: !include-raw-escape: shell/repo-patch.sh
311
312# publisher to clean up the workspace after the build whatever the result
313- publisher:
314 name: onf-infra-wscleanup-publisher
315 publishers:
316 - workspace-cleanup:
317 clean-if:
318 - success: true
319 - unstable: true
320 - failure: true
321 - aborted: true
322 - not-built: true
323 dirmatch: false
324 fail-build: true
325 clean-parent: false
326 disable-deferred-wipeout: false