6f4db494b8bf79b2e4d9ea67eb9a4684adef50b6
[releng/global-jjb.git] / jjb / lf-c-cpp-jobs.yaml
1 ---
2 ###############
3 # CMAKE SONAR #
4 ###############
5
6 - lf_cmake_sonar: &lf_cmake_sonar
7     name: lf-cmake-sonar
8
9     ######################
10     # Default parameters #
11     ######################
12
13     branch: master
14     build-days-to-keep: 7
15     build-dir: "$WORKSPACE/target"
16     build-timeout: 15
17     cmake-opts: ""
18     cron: "@daily"
19     disable-job: false
20     git-url: "$GIT_URL/$PROJECT"
21     github-url: "https://github.com"
22     install-prefix: "$BUILD_DIR/output"
23     make-opts: ""
24     pre-build: ""
25     sonar-scanner-version: 3.3.0.1492
26     sonarcloud-api-token: ""
27     sonarcloud-organization: ""
28     sonarcloud-project-key: ""
29     stream: master
30     submodule-recursive: true
31     submodule-timeout: 10
32     submodule-disable: false
33
34     #####################
35     # Job Configuration #
36     #####################
37
38     project-type: freestyle
39     node: "{build-node}"
40     disabled: "{disable-job}"
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           lftools-version: "{lftools-version}"
52       - lf-cmake-parameters:
53           build-dir: "{build-dir}"
54           cmake-opts: "{cmake-opts}"
55           install-prefix: "{install-prefix}"
56           make-opts: "{make-opts}"
57
58     wrappers:
59       - lf-infra-wrappers:
60           build-timeout: "{build-timeout}"
61           jenkins-ssh-credential: "{jenkins-ssh-credential}"
62
63     builders:
64       - lf-infra-pre-build
65       - shell: "{pre-build}"
66       - inject:
67           # Switch this to the sonar wrapper when JJB 2.0 is available
68           properties-content: |
69             SONAR_HOST_URL=https://sonarcloud.io
70             SONAR_SCANNER_VERSION={sonar-scanner-version}
71             PROJECT_KEY={sonarcloud-project-key}
72             PROJECT_ORGANIZATION={sonarcloud-organization}
73             API_TOKEN={sonarcloud-api-token}
74       - shell: !include-raw-escape: ../shell/cmake-sonar.sh
75       - lf-provide-maven-settings-cleanup
76
77     publishers:
78       - lf-infra-publish
79
80 - job-template:
81     name: "{project-name}-cmake-sonar"
82     id: gerrit-cmake-sonar
83     concurrent: false
84     <<: *lf_cmake_sonar
85
86     scm:
87       - lf-infra-gerrit-scm:
88           branch: "$GERRIT_BRANCH"
89           jenkins-ssh-credential: "{jenkins-ssh-credential}"
90           git-url: "{git-url}"
91           refspec: "$GERRIT_REFSPEC"
92           submodule-recursive: "{submodule-recursive}"
93           submodule-timeout: "{submodule-timeout}"
94           submodule-disable: "{submodule-disable}"
95           choosing-strategy: gerrit
96
97     triggers:
98       - timed: "{obj:cron}"
99       - gerrit:
100           server-name: "{gerrit-server-name}"
101           trigger-on:
102             - comment-added-contains-event:
103                 comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
104           projects:
105             - project-compare-type: "ANT"
106               project-pattern: "{project}"
107               branches:
108                 - branch-compare-type: "ANT"
109                   branch-pattern: "**/{branch}"
110
111 - job-template:
112     name: "{project-name}-cmake-sonar"
113     id: github-cmake-sonar
114     concurrent: false
115     <<: *lf_cmake_sonar
116
117     properties:
118       - lf-infra-properties:
119           build-days-to-keep: "{build-days-to-keep}"
120       - github:
121           url: "{github-url}/{github-org}/{project}"
122
123     scm:
124       - lf-infra-github-scm:
125           url: "{git-clone-url}{github-org}/{project}"
126           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
127           branch: "$sha1"
128           submodule-recursive: "{submodule-recursive}"
129           submodule-timeout: "{submodule-timeout}"
130           submodule-disable: "{submodule-disable}"
131           choosing-strategy: default
132           jenkins-ssh-credential: "{jenkins-ssh-credential}"
133
134     triggers:
135       - timed: "{obj:cron}"
136
137 ###################
138 # CMAKE SONARQUBE #
139 ###################
140
141 - lf_cmake_sonarqube: &lf_cmake_sonarqube
142     name: lf-cmake-sonarqube
143
144     ######################
145     # Default parameters #
146     ######################
147
148     archive-artifacts: >
149       **/*.log
150     branch: master # Sonar should always be run on master branch
151     build-days-to-keep: 7
152     build-dir: "$WORKSPACE/build"
153     build-timeout: 15
154     build-wrap-dir: "$WORKSPACE/bw-output"
155     cmake-opts: ""
156     cron: "@weekly"
157     disable-job: false
158     git-url: "$GIT_URL/$PROJECT"
159     github-url: "https://github.com"
160     install-prefix: "$BUILD_DIR/output"
161     make-opts: ""
162     pre-build: ""
163     stream: master
164     submodule-recursive: true
165     submodule-timeout: 10
166     submodule-disable: false
167
168     # Sonar properties
169     sonar-additional-args: ""
170     sonar-java-opts: ""
171     sonar-project-file: "sonar-project.properties"
172     sonar-properties: ""
173     sonar-task: ""
174
175     #####################
176     # Job Configuration #
177     #####################
178
179     project-type: freestyle
180     node: "{build-node}"
181     disabled: "{disable-job}"
182
183     properties:
184       - lf-infra-properties:
185           build-days-to-keep: "{build-days-to-keep}"
186
187     wrappers:
188       - lf-infra-wrappers:
189           build-timeout: "{build-timeout}"
190           jenkins-ssh-credential: "{jenkins-ssh-credential}"
191
192     parameters:
193       - lf-infra-parameters:
194           project: "{project}"
195           branch: "{branch}"
196           stream: "{stream}"
197       - lf-cmake-parameters:
198           build-dir: "{build-dir}"
199           cmake-opts: "{cmake-opts}"
200           install-prefix: "{install-prefix}"
201           make-opts: "{make-opts}"
202       - string:
203           name: ARCHIVE_ARTIFACTS
204           default: "{archive-artifacts}"
205           description: Artifacts to archive to the logs server.
206       - string:
207           name: BUILD_WRAP_DIR
208           default: "{build-wrap-dir}"
209           description: SonarQube build wrapper output directory.
210
211     builders:
212       - lf-infra-pre-build
213       - shell: "{pre-build}"
214       - shell: !include-raw-escape: ../shell/cmake-sonarqube.sh
215       - lf-infra-sonar:
216           sonar-task: "{sonar-task}"
217           sonar-project-file: "{sonar-project-file}"
218           sonar-properties: "{sonar-properties}"
219           sonar-java-opts: "{sonar-java-opts}"
220           sonar-additional-args: "{sonar-additional-args}"
221
222     publishers:
223       - lf-infra-publish
224
225 - job-template:
226     name: "{project-name}-cmake-sonarqube"
227     id: gerrit-cmake-sonarqube
228     concurrent: false
229     <<: *lf_cmake_sonarqube
230
231     ######################
232     # Default parameters #
233     ######################
234
235     gerrit_sonar_triggers:
236       - comment-added-contains-event:
237           comment-contains-value: '^Patch Set\s+\d+:\s+run-sonar\s*$'
238
239     scm:
240       - lf-infra-gerrit-scm:
241           branch: "$GERRIT_BRANCH"
242           jenkins-ssh-credential: "{jenkins-ssh-credential}"
243           git-url: "{git-url}"
244           refspec: "$GERRIT_REFSPEC"
245           submodule-recursive: "{submodule-recursive}"
246           submodule-timeout: "{submodule-timeout}"
247           submodule-disable: "{submodule-disable}"
248           choosing-strategy: default
249
250     triggers:
251       - timed: "{obj:cron}"
252       - gerrit:
253           server-name: "{gerrit-server-name}"
254           trigger-on: "{obj:gerrit_sonar_triggers}"
255           projects:
256             - project-compare-type: "ANT"
257               project-pattern: "{project}"
258               branches:
259                 - branch-compare-type: "ANT"
260                   branch-pattern: "**/{branch}"
261
262 - job-template:
263     name: "{project-name}-cmake-sonarqube"
264     id: github-cmake-sonarqube
265     concurrent: false
266     <<: *lf_cmake_sonarqube
267
268     scm:
269       - lf-infra-github-scm:
270           branch: "$sha1"
271           jenkins-ssh-credential: "{jenkins-ssh-credential}"
272           url: "{git-clone-url}{github-org}/{project}"
273           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
274           submodule-recursive: "{submodule-recursive}"
275           submodule-timeout: "{submodule-timeout}"
276           submodule-disable: "{submodule-disable}"
277           choosing-strategy: default
278
279     triggers:
280       - github-pull-request:
281           trigger-phrase: "^run-sonar$"
282           only-trigger-phrase: false
283           status-context: "CMake Sonarqube"
284           permit-all: true
285           github-hooks: true
286           white-list-target-branches:
287             - "{branch}"
288
289 ###############
290 # CMAKE STAGE #
291 ###############
292
293 - lf_cmake_stage: &lf_cmake_stage
294     name: lf-cmake-stage
295
296     ######################
297     # Default parameters #
298     ######################
299
300     branch: master
301     build-days-to-keep: 7
302     build-dir: "$WORKSPACE/target"
303     build-timeout: 15
304     cmake-opts: ""
305     cron: "@daily"
306     disable-job: false
307     git-url: "$GIT_URL/$PROJECT"
308     github-url: "https://github.com"
309     install-prefix: "$BUILD_DIR/output"
310     make-opts: ""
311     mvn-global-settings: global-settings
312     pre-build: ""
313     stream: master
314     submodule-recursive: true
315     submodule-timeout: 10
316     submodule-disable: false
317     version: ""
318
319     #####################
320     # Job Configuration #
321     #####################
322
323     project-type: freestyle
324     node: "{build-node}"
325     disabled: "{disable-job}"
326
327     properties:
328       - lf-infra-properties:
329           build-days-to-keep: "{build-days-to-keep}"
330
331     parameters:
332       - lf-infra-parameters:
333           project: "{project}"
334           branch: "{branch}"
335           stream: "{stream}"
336       - lf-cmake-parameters:
337           build-dir: "{build-dir}"
338           cmake-opts: "{cmake-opts}"
339           install-prefix: "{install-prefix}"
340           make-opts: "{make-opts}"
341       - string:
342           name: NEXUS_GROUP_ID
343           default: "{nexus-group-id}"
344           description: "Project Group ID in Nexus to upload to."
345       - string:
346           name: STAGING_PROFILE_ID
347           default: "{staging-profile-id}"
348           description: "Nexus staging profile ID."
349       - string:
350           name: VERSION
351           default: "{version}"
352           description: |
353             (default: '')
354
355             Project version to stage release as. There are 2 methods for
356             using this value:
357
358                 1) Defined explicitly here.
359                 2) Leave this value blank and set /tmp/artifact_version
360
361             Use method 2 in conjunction with 'pre-build' configuration to
362             generate the artifact_version automatically from files in the
363             project's repository. For example with pre-build script:
364
365             #!/bin/bash
366             MAJOR_VERSION="$(grep 'set(OCIO_VERSION_MAJOR' CMakeLists.txt \
367                 | awk '{{print $NF}}' | awk -F')' '{{print $1}}')"
368             MINOR_VERSION="$(grep 'set(OCIO_VERSION_MINOR' CMakeLists.txt \
369                 | awk '{{print $NF}}' | awk -F')' '{{print $1}}')"
370             PATCH_VERSION="$(grep 'set(OCIO_VERSION_PATCH' CMakeLists.txt \
371                 | awk '{{print $NF}}' | awk -F')' '{{print $1}}')"
372             echo "${{MAJOR_VERSION}}.${{MINOR_VERSION}}.${{PATCH_VERSION}}" > /tmp/artifact_version
373
374     wrappers:
375       - lf-infra-wrappers:
376           build-timeout: "{build-timeout}"
377           jenkins-ssh-credential: "{jenkins-ssh-credential}"
378
379     builders:
380       - lf-infra-pre-build
381       - lf-provide-maven-settings:
382           global-settings-file: "{mvn-global-settings}"
383           settings-file: "{mvn-settings}"
384       - lf-infra-create-netrc:
385           server-id: staging
386       - shell: "{pre-build}"
387       - shell: !include-raw-escape: ../shell/cmake-build.sh
388       - shell: !include-raw-escape: ../shell/cmake-stage.sh
389       - lf-provide-maven-settings-cleanup
390
391     publishers:
392       - lf-infra-publish
393
394 - job-template:
395     name: "{project-name}-cmake-stage-{stream}"
396     id: gerrit-cmake-stage
397     concurrent: true
398     <<: *lf_cmake_stage
399
400     scm:
401       - lf-infra-gerrit-scm:
402           branch: "$GERRIT_BRANCH"
403           jenkins-ssh-credential: "{jenkins-ssh-credential}"
404           git-url: "{git-url}"
405           refspec: "$GERRIT_REFSPEC"
406           submodule-recursive: "{submodule-recursive}"
407           submodule-timeout: "{submodule-timeout}"
408           submodule-disable: "{submodule-disable}"
409           choosing-strategy: gerrit
410
411     triggers:
412       - timed: "{obj:cron}"
413       - gerrit:
414           server-name: "{gerrit-server-name}"
415           trigger-on:
416             - comment-added-contains-event:
417                 comment-contains-value: '^Patch Set\s+\d+:\s+stage-release\s*$'
418           projects:
419             - project-compare-type: "ANT"
420               project-pattern: "{project}"
421               branches:
422                 - branch-compare-type: "ANT"
423                   branch-pattern: "**/{branch}"
424
425 - job-template:
426     name: "{project-name}-cmake-stage-{stream}"
427     id: github-cmake-stage
428     concurrent: true
429     <<: *lf_cmake_stage
430
431     properties:
432       - lf-infra-properties:
433           build-days-to-keep: "{build-days-to-keep}"
434       - github:
435           url: "{github-url}/{github-org}/{project}"
436
437     scm:
438       - lf-infra-github-scm:
439           url: "{git-clone-url}{github-org}/{project}"
440           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
441           branch: "$sha1"
442           submodule-recursive: "{submodule-recursive}"
443           submodule-timeout: "{submodule-timeout}"
444           submodule-disable: "{submodule-disable}"
445           choosing-strategy: default
446           jenkins-ssh-credential: "{jenkins-ssh-credential}"
447
448     triggers:
449       - timed: "{obj:cron}"
450       - github-pull-request:
451           trigger-phrase: "^(stage-release)$"
452           only-trigger-phrase: true
453           status-context: "CMake Stage"
454           permit-all: true
455           github-hooks: true
456           white-list-target-branches:
457             - "{branch}"
458
459 ################
460 # CMAKE VERIFY #
461 ################
462
463 - lf_cmake_verify: &lf_cmake_verify
464     name: lf-cmake-verify
465
466     ######################
467     # Default parameters #
468     ######################
469
470     branch: master
471     build-days-to-keep: 7
472     build-dir: "$WORKSPACE/target"
473     build-timeout: 15
474     cmake-opts: ""
475     disable-job: false
476     git-url: "$GIT_URL/$PROJECT"
477     github-url: "https://github.com"
478     install-prefix: "$BUILD_DIR/output"
479     make-opts: ""
480     pre-build: ""
481     stream: master
482     submodule-recursive: true
483     submodule-timeout: 10
484     submodule-disable: false
485
486     gerrit_verify_triggers:
487       - patchset-created-event:
488           exclude-drafts: true
489           exclude-trivial-rebase: false
490           exclude-no-code-change: false
491       - draft-published-event
492       - comment-added-contains-event:
493           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
494
495     gerrit_trigger_file_paths:
496       - compare-type: REG_EXP
497         pattern: ".*"
498
499     # github_included_regions MUST match gerrit_trigger_file_paths
500     github_included_regions:
501       - ".*"
502
503     #####################
504     # Job Configuration #
505     #####################
506
507     project-type: freestyle
508     node: "{build-node}"
509     disabled: "{disable-job}"
510
511     properties:
512       - lf-infra-properties:
513           build-days-to-keep: "{build-days-to-keep}"
514
515     parameters:
516       - lf-infra-parameters:
517           project: "{project}"
518           branch: "{branch}"
519           stream: "{stream}"
520       - lf-cmake-parameters:
521           build-dir: "{build-dir}"
522           cmake-opts: "{cmake-opts}"
523           install-prefix: "{install-prefix}"
524           make-opts: "{make-opts}"
525
526     wrappers:
527       - lf-infra-wrappers:
528           build-timeout: "{build-timeout}"
529           jenkins-ssh-credential: "{jenkins-ssh-credential}"
530
531     builders:
532       - shell: "{pre-build}"
533       - shell: !include-raw-escape: ../shell/cmake-build.sh
534
535     publishers:
536       - lf-infra-publish
537
538 - job-template:
539     name: "{project-name}-cmake-verify-{stream}"
540     id: gerrit-cmake-verify
541     concurrent: true
542     <<: *lf_cmake_verify
543
544     scm:
545       - lf-infra-gerrit-scm:
546           branch: "$GERRIT_BRANCH"
547           jenkins-ssh-credential: "{jenkins-ssh-credential}"
548           git-url: "{git-url}"
549           refspec: "$GERRIT_REFSPEC"
550           submodule-recursive: "{submodule-recursive}"
551           submodule-timeout: "{submodule-timeout}"
552           submodule-disable: "{submodule-disable}"
553           choosing-strategy: gerrit
554
555     triggers:
556       - gerrit:
557           server-name: "{gerrit-server-name}"
558           trigger-on: "{obj:gerrit_verify_triggers}"
559           projects:
560             - project-compare-type: "ANT"
561               project-pattern: "{project}"
562               branches:
563                 - branch-compare-type: "ANT"
564                   branch-pattern: "**/{branch}"
565               file-paths: "{obj:gerrit_trigger_file_paths}"
566
567 - job-template:
568     name: "{project-name}-cmake-verify-{stream}"
569     id: github-cmake-verify
570     concurrent: true
571     <<: *lf_cmake_verify
572
573     properties:
574       - lf-infra-properties:
575           build-days-to-keep: "{build-days-to-keep}"
576       - github:
577           url: "{github-url}/{github-org}/{project}"
578
579     scm:
580       - lf-infra-github-scm:
581           url: "{git-clone-url}{github-org}/{project}"
582           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
583           branch: "$sha1"
584           submodule-recursive: "{submodule-recursive}"
585           submodule-timeout: "{submodule-timeout}"
586           submodule-disable: "{submodule-disable}"
587           choosing-strategy: default
588           jenkins-ssh-credential: "{jenkins-ssh-credential}"
589
590     triggers:
591       - github-pull-request:
592           trigger-phrase: "^(recheck|reverify)$"
593           only-trigger-phrase: false
594           status-context: "CMake Verify"
595           permit-all: true
596           github-hooks: true
597           included-regions: "{obj:github_included_regions}"
598           white-list-target-branches:
599             - "{branch}"