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