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