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