9b077e4adadc896a2bad5b88551617ff709f5cfd
[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           included-regions: '{obj:github_included_regions}'
217
218 ########################
219 # Python Sonar with Tox #
220 ########################
221
222 - lf_tox_sonar: &lf_tox_sonar
223     name: lf-tox_sonar
224
225     ######################
226     # Default parameters #
227     ######################
228
229     branch: master  # Sonar should always be run on master branch
230     build-days-to-keep: 7
231     build-timeout: 60
232     cron: 'H H * * *'  # run daily
233     git-url: '$GIT_URL/$PROJECT'
234     github-url: 'https://github.com'
235     java-version: openjdk8
236     python-version: python2
237     mvn-global-settings: global-settings
238     mvn-settings: '{mvn-settings}'
239     mvn-version: mvn35
240     sonar-mvn-goal: 'sonar:sonar'
241     stream: master
242     submodule-recursive: true
243
244     gerrit_trigger_file_paths:
245       - compare-type: REG_EXP
246         pattern: '.*'
247
248     # github_included_regions MUST match gerrit_trigger_file_paths
249     github_included_regions:
250       - '.*'
251
252     #####################
253     # Job Configuration #
254     #####################
255
256     parameters:
257       - lf-infra-parameters:
258           project: '{project}'
259           branch: '{branch}'
260           stream: '{stream}'
261           lftools-version: '{lftools-version}'
262       - string:
263           name: ARCHIVE_ARTIFACTS
264           default: '{archive-artifacts}'
265           description: Artifacts to archive to the logs server.
266       - string:
267           name: MVN
268           # Sets an env var for shell scripts to be able to call the dynamically
269           # installed maven without having to calculate the path themselves.
270           # yamllint disable-line rule:line-length
271           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{mvn-version}/bin/mvn'
272           description: 'Maven selector to be used by shell scripts'
273       - string:
274           name: SONAR_MAVEN_GOAL
275           default: '{sonar-mvn-goal}'
276           description: |
277               Maven goals to pass to the Sonar call. Typically sonar:sonar
278               however to use a specific version of the sonar-maven-plugin we
279               can call "org.codehaus.mojo:sonar-maven-plugin:3.3.0.603:sonar".
280
281     builders:
282       - shell: !include-raw-escape:
283           # Workaround issue where the tox run later breaks the lftools virtualenv.
284           # Without running the install first the run in the publisher will fail
285           # due to missing lftools because it gets installed into a tox venv.
286           - ../shell/lftools-install.sh
287       - lf-infra-tox-install:
288           python-version: '{python-version}'
289       - shell: !include-raw-escape: ../shell/tox-run.sh
290       - lf-provide-maven-settings:
291           global-settings-file: '{mvn-global-settings}'
292           settings-file: '{mvn-settings}'
293       - lf-infra-tox-sonar:
294           java-version: '{java-version}'
295           mvn-settings: '{mvn-settings}'
296           mvn-version: '{mvn-version}'
297
298     publishers:
299       - lf-infra-publish
300
301 - builder:
302     name: lf-infra-tox-sonar
303     # Run a Sonar build with Maven
304     builders:
305       - lf-maven-install:
306           mvn-version: '{mvn-version}'
307       - lf-update-java-alternatives:
308           java-version: '{java-version}'
309       - inject:
310           # TODO: Switch this to the sonar wrapper when JJB 2.0 is available
311           properties-content: SONAR_HOST_URL=$SONAR_URL
312       - shell: !include-raw-escape:
313           - ../shell/common-variables.sh
314           - ../shell/maven-sonar.sh
315       - lf-provide-maven-settings-cleanup
316
317 - job-template:
318     name: '{project-name}-tox-sonar'
319     id: gerrit-tox-sonar
320     <<: *lf_python_common
321     # yamllint disable-line rule:key-duplicates
322     <<: *lf_tox_sonar
323
324     ######################
325     # Default parameters #
326     ######################
327
328     gerrit_sonar_triggers:
329       - comment-added-contains-event:
330           comment-contains-value: run-sonar$
331
332     #####################
333     # Job Configuration #
334     #####################
335
336     scm:
337       - lf-infra-gerrit-scm:
338           jenkins-ssh-credential: '{jenkins-ssh-credential}'
339           git-url: '{git-url}'
340           refspec: $GERRIT_REFSPEC
341           branch: $GERRIT_BRANCH
342           submodule-recursive: '{submodule-recursive}'
343           choosing-strategy: default
344
345     triggers:
346       - timed: '{obj:cron}'
347       - gerrit:
348           server-name: '{gerrit-server-name}'
349           trigger-on: '{obj:gerrit_sonar_triggers}'
350           projects:
351             - project-compare-type: 'ANT'
352               project-pattern: '{project}'
353               branches:
354                 - branch-compare-type: 'ANT'
355                   branch-pattern: '**/{branch}'
356               file-paths: '{obj:gerrit_trigger_file_paths}'
357           skip-vote:
358             successful: true
359             failed: true
360             unstable: true
361             notbuilt: true
362
363 - job-template:
364     name: '{project-name}-tox-sonar'
365     id: github-tox-sonar
366     <<: *lf_python_common
367     # yamllint disable-line rule:key-duplicates
368     <<: *lf_tox_sonar
369
370     properties:
371       - lf-infra-properties:
372           build-days-to-keep: '{build-days-to-keep}'
373       - github:
374           url: '{github-url}/{github-org}/{project}'
375
376     scm:
377       - lf-infra-github-scm:
378           url: '{git-clone-url}{github-org}/{project}'
379           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
380           branch: '$sha1'
381           submodule-recursive: '{submodule-recursive}'
382           choosing-strategy: default
383           jenkins-ssh-credential: '{jenkins-ssh-credential}'
384
385     triggers:
386       - github-pull-request:
387           trigger-phrase: '^run-sonar$'
388           only-trigger-phrase: false
389           status-context: 'Python Sonar'
390           permit-all: true
391           github-hooks: true
392           included-regions: '{obj:github_included_regions}'
393
394 ##############
395 # Tox Verify #
396 ##############
397
398 - lf_tox_verify: &lf_tox_verify
399     name: lf-tox-verify
400
401     ######################
402     # Default parameters #
403     ######################
404
405     branch: master
406     build-days-to-keep: 7
407     build-timeout: 15
408     git-url: '$GIT_URL/$GERRIT_PROJECT'
409     github-url: 'https://github.com'
410     parallel: true
411     python-version: python2
412     stream: master
413     submodule-recursive: true
414     tox-dir: ''
415     tox-envs: ''
416
417     gerrit_trigger_file_paths:
418       - compare-type: REG_EXP
419         pattern: '.*'
420
421     # github_included_regions MUST match gerrit_trigger_file_paths
422     github_included_regions:
423       - '.*'
424
425     #####################
426     # Job Configuration #
427     #####################
428
429     project-type: freestyle
430     node: '{build-node}'
431     concurrent: true
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           lftools-version: '{lftools-version}'
443       - lf-infra-tox-parameters:
444           tox-dir: '{tox-dir}'
445           tox-envs: '{tox-envs}'
446       - bool:
447           name: PARALLEL
448           default: '{parallel}'
449           description: Tox test type used to configure serial or parallel testing.
450
451     wrappers:
452       - lf-infra-wrappers:
453           build-timeout: '{build-timeout}'
454           jenkins-ssh-credential: '{jenkins-ssh-credential}'
455
456     builders:
457       - shell: !include-raw-escape:
458           # Workaround issue where the tox run later breaks the lftools virtualenv.
459           # Without running the install first the run in the publisher will fail
460           # due to missing lftools because it gets installed into a tox venv.
461           - ../shell/lftools-install.sh
462       - lf-infra-tox-install:
463           python-version: '{python-version}'
464       - shell: !include-raw-escape: ../shell/tox-run.sh
465
466     publishers:
467       - lf-infra-publish
468
469 - job-template:
470     # Python projects typically use tox to run testing.
471     name: '{project-name}-tox-verify-{stream}'
472     id: gerrit-tox-verify
473     <<: *lf_tox_verify
474
475     ######################
476     # Default parameters #
477     ######################
478
479     gerrit_verify_triggers:
480       - patchset-created-event:
481           exclude-drafts: true
482           exclude-trivial-rebase: false
483           exclude-no-code-change: false
484       - draft-published-event
485       - comment-added-contains-event:
486           comment-contains-value: '^Patch Set[ ]+[0-9]+:([ ]+|[\n]+)(recheck|reverify)$'
487
488     #####################
489     # Job Configuration #
490     #####################
491
492     scm:
493       - lf-infra-gerrit-scm:
494           jenkins-ssh-credential: '{jenkins-ssh-credential}'
495           git-url: '{git-url}'
496           refspec: '$GERRIT_REFSPEC'
497           branch: '$GERRIT_BRANCH'
498           submodule-recursive: '{submodule-recursive}'
499           choosing-strategy: gerrit
500
501     triggers:
502       - gerrit:
503           server-name: '{gerrit-server-name}'
504           trigger-on: '{obj:gerrit_verify_triggers}'
505           projects:
506             - project-compare-type: ANT
507               project-pattern: '{project}'
508               branches:
509                 - branch-compare-type: ANT
510                   branch-pattern: '**/{branch}'
511               file-paths: '{obj:gerrit_trigger_file_paths}'
512
513 - job-template:
514     # Python projects typically use tox to run testing.
515     name: '{project-name}-tox-verify-{stream}'
516     id: github-tox-verify
517     <<: *lf_tox_verify
518
519     properties:
520       - lf-infra-properties:
521           build-days-to-keep: '{build-days-to-keep}'
522       - github:
523           url: '{github-url}/{github-org}/{project}'
524
525     scm:
526       - lf-infra-github-scm:
527           url: '{git-clone-url}{github-org}/{project}'
528           refspec: '+refs/pull/*:refs/remotes/origin/pr/*'
529           branch: '$sha1'
530           submodule-recursive: '{submodule-recursive}'
531           choosing-strategy: default
532           jenkins-ssh-credential: '{jenkins-ssh-credential}'
533
534     triggers:
535       - github-pull-request:
536           trigger-phrase: '^(recheck|reverify)$'
537           only-trigger-phrase: false
538           status-context: 'Tox Verify'
539           permit-all: true
540           github-hooks: true
541           included-regions: '{obj:github_included_regions}'