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