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