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