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