Update gerrit comment trigger keywords with regex
[releng/global-jjb.git] / jjb / lf-python-jobs.yaml
1 ---
2
3 ##########
4 # Macros #
5 ##########
6
7 - builder:
8     name: lf-infra-tox-install
9     builders:
10       - inject:
11           properties-content: 'PYTHON_VERSION={python-version}'
12       - shell: !include-raw-escape: ../shell/tox-install.sh
13
14 - builder:
15     name: lf-infra-clm-python
16     builders:
17       - inject:
18           properties-content: 'CLM_PROJECT_NAME={clm-project-name}'
19       - shell: !include-raw-escape:
20           - ../shell/nexus-iq-cli.sh
21
22 ####################
23 # COMMON FUNCTIONS #
24 ####################
25
26 - lf_python_common: &lf_python_common
27     name: lf-python-common
28
29     ######################
30     # Default parameters #
31     ######################
32
33     archive-artifacts: >
34       **/*.log
35
36     #####################
37     # Job Configuration #
38     #####################
39
40     project-type: freestyle
41     node: '{build-node}'
42
43     properties:
44       - lf-infra-properties:
45           build-days-to-keep: '{build-days-to-keep}'
46
47     parameters:
48       - lf-infra-parameters:
49           project: '{project}'
50           branch: '{branch}'
51           stream: '{stream}'
52
53     wrappers:
54       - lf-infra-wrappers:
55           build-timeout: '{build-timeout}'
56           jenkins-ssh-credential: '{jenkins-ssh-credential}'
57
58     publishers:
59       - lf-infra-publish
60
61 #################
62 # Python XC CLM #
63 #################
64
65 - lf_python_clm_xc: &lf_python_xc_clm
66     name: lf-python-xc-clm
67
68     ######################
69     # Default parameters #
70     ######################
71
72     branch: master
73     build-days-to-keep: 30  # 30 days for troubleshooting purposes
74     build-timeout: 60
75     disable-job: false
76     git-url: '$GIT_URL/$PROJECT'
77     github-url: 'https://github.com'
78     java-version: openjdk8
79     nexus-iq-cli-version: 1.44.0-01
80     nexus-iq-namespace: ''  # Recommend a trailing dash when set. Example: odl-
81     stream: master
82     submodule-recursive: true
83     submodule-timeout: 10
84     submodule-disable: false
85
86     gerrit_trigger_file_paths:
87       - compare-type: ANT
88         pattern: '.*'
89
90     # github_included_regions MUST match gerrit_trigger_file_paths
91     github_included_regions:
92       - '.*'
93
94     #####################
95     # Job Configuration #
96     #####################
97
98     disabled: '{disable-job}'
99
100     parameters:
101       - lf-infra-parameters:
102           project: '{project}'
103           branch: '{branch}'
104           stream: '{stream}'
105       - string:
106           name: NEXUS_IQ_CLI_VERSION
107           default: '{nexus-iq-cli-version}'
108           description: Nexus IQ CLI package to download and use.
109
110     wrappers:
111       - credentials-binding:
112           - username-password-separated:
113               credential-id: nexus-iq-xc-clm
114               username: CLM_USER
115               password: CLM_PASSWORD
116     builders:
117       - lf-update-java-alternatives:
118           java-version: '{java-version}'
119       - lf-infra-clm-python:
120           clm-project-name: '{nexus-iq-namespace}{project-name}'
121
122 - job-template:
123     name: '{project-name}-python-clm-{stream}'
124     id: gerrit-python-xc-clm
125     <<: *lf_python_common
126     # yamllint disable-line rule:key-duplicates
127     <<: *lf_python_xc_clm
128
129     ######################
130     # Default parameters #
131     ######################
132
133     gerrit_clm_triggers:
134       - comment-added-contains-event:
135           comment-contains-value: '^Patch Set\s+\d+:\s+run-clm\s*$'
136
137     #####################
138     # Job Configuration #
139     #####################
140
141     scm:
142       - lf-infra-gerrit-scm:
143           jenkins-ssh-credential: '{jenkins-ssh-credential}'
144           git-url: '{git-url}'
145           refspec: '$GERRIT_REFSPEC'
146           branch: '$GERRIT_BRANCH'
147           submodule-recursive: '{submodule-recursive}'
148           submodule-timeout: '{submodule-timeout}'
149           submodule-disable: '{submodule-disable}'
150           choosing-strategy: default
151
152     triggers:
153       # Build weekly on Saturdays
154       - timed: 'H H * * 6'
155       - gerrit:
156           server-name: '{gerrit-server-name}'
157           trigger-on: '{obj:gerrit_clm_triggers}'
158           projects:
159             - project-compare-type: ANT
160               project-pattern: '{project}'
161               branches:
162                 - branch-compare-type: ANT
163                   branch-pattern: '**/{branch}'
164               file-paths: '{obj:gerrit_trigger_file_paths}'
165           skip-vote:
166             successful: true
167             failed: true
168             unstable: true
169             notbuilt: true
170
171 - job-template:
172     name: '{project-name}-python-clm-{stream}'
173     id: github-python-xc-clm
174     <<: *lf_python_common
175     # yamllint disable-line rule:key-duplicates
176     <<: *lf_python_xc_clm
177
178     properties:
179       - lf-infra-properties:
180           build-days-to-keep: '{build-days-to-keep}'
181       - github:
182           url: '{github-url}/{github-org}/{project}'
183
184     scm:
185       - lf-infra-github-scm:
186           url: '{git-clone-url}{github-org}/{project}'
187           refspec: ''
188           branch: 'refs/heads/{branch}'
189           submodule-recursive: '{submodule-recursive}'
190           submodule-timeout: '{submodule-timeout}'
191           submodule-disable: '{submodule-disable}'
192           choosing-strategy: default
193           jenkins-ssh-credential: '{jenkins-ssh-credential}'
194
195     triggers:
196       # Build weekly on Saturdays
197       - timed: 'H H * * 6'
198       - github-pull-request:
199           trigger-phrase: '^run-clm$'
200           only-trigger-phrase: false
201           status-context: 'CLM'
202           permit-all: true
203           github-hooks: true
204           white-list-target-branches:
205             - '{branch}'
206           included-regions: '{obj:github_included_regions}'
207
208 ########################
209 # Python Sonar with Tox #
210 ########################
211
212 - lf_tox_sonar: &lf_tox_sonar
213     name: lf-tox_sonar
214
215     ######################
216     # Default parameters #
217     ######################
218
219     branch: master  # Sonar should always be run on master branch
220     build-days-to-keep: 7
221     build-timeout: 60
222     cron: 'H H * * *'  # run daily
223     disable-job: false
224     git-url: '$GIT_URL/$PROJECT'
225     github-url: 'https://github.com'
226     java-version: openjdk8
227     python-version: python2
228     mvn-global-settings: global-settings
229     mvn-settings: '{mvn-settings}'
230     mvn-version: mvn35
231     sonar-mvn-goal: 'sonar:sonar'
232     stream: master
233     submodule-recursive: true
234     submodule-timeout: 10
235     submodule-disable: false
236
237     gerrit_trigger_file_paths:
238       - compare-type: REG_EXP
239         pattern: '.*'
240
241     # github_included_regions MUST match gerrit_trigger_file_paths
242     github_included_regions:
243       - '.*'
244
245     #####################
246     # Job Configuration #
247     #####################
248
249     disabled: '{disable-job}'
250
251     parameters:
252       - lf-infra-parameters:
253           project: '{project}'
254           branch: '{branch}'
255           stream: '{stream}'
256       - string:
257           name: ARCHIVE_ARTIFACTS
258           default: '{archive-artifacts}'
259           description: Artifacts to archive to the logs server.
260       - string:
261           name: MVN
262           # Sets an env var for shell scripts to be able to call the dynamically
263           # installed maven without having to calculate the path themselves.
264           # yamllint disable-line rule:line-length
265           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn'
266           description: 'Maven selector to be used by shell scripts'
267       - string:
268           name: SONAR_MAVEN_GOAL
269           default: '{sonar-mvn-goal}'
270           description: |
271               Maven goals to pass to the Sonar call. Typically sonar:sonar
272               however to use a specific version of the sonar-maven-plugin we
273               can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
274
275     builders:
276       - lf-infra-pre-build
277       - lf-infra-tox-install:
278           python-version: '{python-version}'
279       - shell: !include-raw-escape: ../shell/tox-run.sh
280       - lf-provide-maven-settings:
281           global-settings-file: '{mvn-global-settings}'
282           settings-file: '{mvn-settings}'
283       - lf-infra-tox-sonar:
284           java-version: '{java-version}'
285           mvn-settings: '{mvn-settings}'
286           mvn-version: '{mvn-version}'
287
288     publishers:
289       - lf-infra-publish
290
291 - builder:
292     name: lf-infra-tox-sonar
293     # Run a Sonar build with Maven
294     builders:
295       - lf-maven-install:
296           mvn-version: '{mvn-version}'
297       - lf-update-java-alternatives:
298           java-version: '{java-version}'
299       - inject:
300           # TODO: Switch this to the sonar wrapper when JJB 2.0 is available
301           properties-content: SONAR_HOST_URL=$SONAR_URL
302       - shell: !include-raw-escape:
303           - ../shell/common-variables.sh
304           - ../shell/maven-sonar.sh
305       - lf-provide-maven-settings-cleanup
306
307 - job-template:
308     name: '{project-name}-tox-sonar'
309     id: gerrit-tox-sonar
310     <<: *lf_python_common
311     # yamllint disable-line rule:key-duplicates
312     <<: *lf_tox_sonar
313
314     ######################
315     # Default parameters #
316     ######################
317
318     gerrit_sonar_triggers:
319       - comment-added-contains-event:
320           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
321
322     #####################
323     # Job Configuration #
324     #####################
325
326     scm:
327       - lf-infra-gerrit-scm:
328           jenkins-ssh-credential: '{jenkins-ssh-credential}'
329           git-url: '{git-url}'
330           refspec: $GERRIT_REFSPEC
331           branch: $GERRIT_BRANCH
332           submodule-recursive: '{submodule-recursive}'
333           submodule-timeout: '{submodule-timeout}'
334           submodule-disable: '{submodule-disable}'
335           choosing-strategy: default
336
337     triggers:
338       - timed: '{obj:cron}'
339       - gerrit:
340           server-name: '{gerrit-server-name}'
341           trigger-on: '{obj:gerrit_sonar_triggers}'
342           projects:
343             - project-compare-type: 'ANT'
344               project-pattern: '{project}'
345               branches:
346                 - branch-compare-type: 'ANT'
347                   branch-pattern: '**/{branch}'
348               file-paths: '{obj:gerrit_trigger_file_paths}'
349           skip-vote:
350             successful: true
351             failed: true
352             unstable: true
353             notbuilt: true
354
355 - job-template:
356     name: '{project-name}-tox-sonar'
357     id: github-tox-sonar
358     <<: *lf_python_common
359     # yamllint disable-line rule:key-duplicates
360     <<: *lf_tox_sonar
361
362     properties:
363       - lf-infra-properties:
364           build-days-to-keep: '{build-days-to-keep}'
365       - github:
366           url: '{github-url}/{github-org}/{project}'
367
368     scm:
369       - lf-infra-github-scm:
370           url: '{git-clone-url}{github-org}/{project}'
371           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
372           branch: '$sha1'
373           submodule-recursive: '{submodule-recursive}'
374           submodule-timeout: '{submodule-timeout}'
375           submodule-disable: '{submodule-disable}'
376           choosing-strategy: default
377           jenkins-ssh-credential: '{jenkins-ssh-credential}'
378
379     triggers:
380       - github-pull-request:
381           trigger-phrase: '^run-sonar$'
382           only-trigger-phrase: false
383           status-context: 'Python Sonar'
384           permit-all: true
385           github-hooks: true
386           white-list-target-branches:
387             - '{branch}'
388           included-regions: '{obj:github_included_regions}'
389
390 ##############
391 # Tox Verify #
392 ##############
393
394 - lf_tox_verify: &lf_tox_verify
395     name: lf-tox-verify
396
397     ######################
398     # Default parameters #
399     ######################
400
401     branch: master
402     build-days-to-keep: 7
403     build-timeout: 15
404     disable-job: false
405     git-url: '$GIT_URL/$GERRIT_PROJECT'
406     github-url: 'https://github.com'
407     parallel: true
408     python-version: python2
409     stream: master
410     submodule-recursive: true
411     submodule-timeout: 10
412     submodule-disable: false
413     tox-dir: ''
414     tox-envs: ''
415
416     gerrit_trigger_file_paths:
417       - compare-type: REG_EXP
418         pattern: '.*'
419
420     # github_included_regions MUST match gerrit_trigger_file_paths
421     github_included_regions:
422       - '.*'
423
424     #####################
425     # Job Configuration #
426     #####################
427
428     project-type: freestyle
429     node: '{build-node}'
430     concurrent: true
431     disabled: '{disable-job}'
432
433     properties:
434       - lf-infra-properties:
435           build-days-to-keep: '{build-days-to-keep}'
436
437     parameters:
438       - lf-infra-parameters:
439           project: '{project}'
440           branch: '{branch}'
441           stream: '{stream}'
442       - lf-infra-tox-parameters:
443           tox-dir: '{tox-dir}'
444           tox-envs: '{tox-envs}'
445       - bool:
446           name: PARALLEL
447           default: '{parallel}'
448           description: Tox test type used to configure serial or parallel testing.
449
450     wrappers:
451       - lf-infra-wrappers:
452           build-timeout: '{build-timeout}'
453           jenkins-ssh-credential: '{jenkins-ssh-credential}'
454
455     builders:
456       - lf-infra-pre-build
457       - lf-infra-tox-install:
458           python-version: '{python-version}'
459       - shell: !include-raw-escape: ../shell/tox-run.sh
460
461     publishers:
462       - lf-infra-publish
463
464 - job-template:
465     # Python projects typically use tox to run testing.
466     name: '{project-name}-tox-verify-{stream}'
467     id: gerrit-tox-verify
468     <<: *lf_tox_verify
469
470     ######################
471     # Default parameters #
472     ######################
473
474     gerrit-skip-vote: false
475     gerrit_verify_triggers:
476       - patchset-created-event:
477           exclude-drafts: true
478           exclude-trivial-rebase: false
479           exclude-no-code-change: false
480       - draft-published-event
481       - comment-added-contains-event:
482           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
483
484     #####################
485     # Job Configuration #
486     #####################
487
488     scm:
489       - lf-infra-gerrit-scm:
490           jenkins-ssh-credential: '{jenkins-ssh-credential}'
491           git-url: '{git-url}'
492           refspec: '$GERRIT_REFSPEC'
493           branch: '$GERRIT_BRANCH'
494           submodule-recursive: '{submodule-recursive}'
495           submodule-timeout: '{submodule-timeout}'
496           submodule-disable: '{submodule-disable}'
497           choosing-strategy: gerrit
498
499     triggers:
500       - gerrit:
501           server-name: '{gerrit-server-name}'
502           trigger-on: '{obj:gerrit_verify_triggers}'
503           projects:
504             - project-compare-type: ANT
505               project-pattern: '{project}'
506               branches:
507                 - branch-compare-type: ANT
508                   branch-pattern: '**/{branch}'
509               file-paths: '{obj:gerrit_trigger_file_paths}'
510           skip-vote:
511             successful: '{gerrit-skip-vote}'
512             failed: '{gerrit-skip-vote}'
513             unstable: '{gerrit-skip-vote}'
514             notbuilt: '{gerrit-skip-vote}'
515
516 - job-template:
517     # Python projects typically use tox to run testing.
518     name: '{project-name}-tox-verify-{stream}'
519     id: github-tox-verify
520     <<: *lf_tox_verify
521
522     properties:
523       - lf-infra-properties:
524           build-days-to-keep: '{build-days-to-keep}'
525       - github:
526           url: '{github-url}/{github-org}/{project}'
527
528     scm:
529       - lf-infra-github-scm:
530           url: '{git-clone-url}{github-org}/{project}'
531           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
532           branch: '$sha1'
533           submodule-recursive: '{submodule-recursive}'
534           submodule-timeout: '{submodule-timeout}'
535           submodule-disable: '{submodule-disable}'
536           choosing-strategy: default
537           jenkins-ssh-credential: '{jenkins-ssh-credential}'
538
539     triggers:
540       - github-pull-request:
541           trigger-phrase: '^(recheck|reverify)$'
542           only-trigger-phrase: false
543           status-context: 'Tox Verify'
544           permit-all: true
545           github-hooks: true
546           white-list-target-branches:
547             - '{branch}'
548           included-regions: '{obj:github_included_regions}'