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