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