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