d82a9bc1b65be9e3b592021af6aadd852fc65f88
[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-prefix: "$BUILD_DIR/output"
296     make-opts: ""
297     mvn-global-settings: global-settings
298     pre-build: ""
299     stream: master
300     submodule-recursive: true
301     submodule-timeout: 10
302     submodule-disable: false
303     version: ""
304
305     parameters:
306       - lf-infra-parameters:
307           project: "{project}"
308           branch: "{branch}"
309           stream: "{stream}"
310       - lf-cmake-parameters:
311           build-dir: "{build-dir}"
312           cmake-opts: "{cmake-opts}"
313           install-prefix: "{install-prefix}"
314           make-opts: "{make-opts}"
315       - string:
316           name: NEXUS_GROUP_ID
317           default: "{nexus-group-id}"
318           description: "Project Group ID in Nexus to upload to."
319       - string:
320           name: STAGING_PROFILE_ID
321           default: "{staging-profile-id}"
322           description: "Nexus staging profile ID."
323       - string:
324           name: VERSION
325           default: "{version}"
326           description: |
327             (default: '')
328
329             Project version to stage release as. There are 2 methods for
330             using this value:
331
332                 1) Defined explicitly here.
333                 2) Leave this value blank and set /tmp/artifact_version
334
335             Use method 2 in conjunction with 'pre-build' configuration to
336             generate the artifact_version automatically from files in the
337             project's repository. For example with pre-build script:
338
339             #!/bin/bash
340             MAJOR_VERSION="$(grep 'set(OCIO_VERSION_MAJOR' CMakeLists.txt \
341                 | awk '{{print $NF}}' | awk -F')' '{{print $1}}')"
342             MINOR_VERSION="$(grep 'set(OCIO_VERSION_MINOR' CMakeLists.txt \
343                 | awk '{{print $NF}}' | awk -F')' '{{print $1}}')"
344             PATCH_VERSION="$(grep 'set(OCIO_VERSION_PATCH' CMakeLists.txt \
345                 | awk '{{print $NF}}' | awk -F')' '{{print $1}}')"
346             echo "${{MAJOR_VERSION}}.${{MINOR_VERSION}}.${{PATCH_VERSION}}" > /tmp/artifact_version
347
348     builders:
349       - lf-infra-pre-build
350       - lf-provide-maven-settings:
351           global-settings-file: "{mvn-global-settings}"
352           settings-file: "{mvn-settings}"
353       - lf-infra-create-netrc:
354           server-id: staging
355       - shell: "{pre-build}"
356       - shell: !include-raw-escape: ../shell/cmake-build.sh
357       - shell: !include-raw-escape: ../shell/cmake-stage.sh
358       - lf-provide-maven-settings-cleanup
359
360 - job-template:
361     name: "{project-name}-cmake-stage-{stream}"
362     id: gerrit-cmake-stage
363     concurrent: true
364     <<: *lf_cmake_common
365     <<: *lf_cmake_stage
366
367     scm:
368       - lf-infra-gerrit-scm:
369           branch: "$GERRIT_BRANCH"
370           jenkins-ssh-credential: "{jenkins-ssh-credential}"
371           git-url: "{git-url}"
372           refspec: "$GERRIT_REFSPEC"
373           submodule-recursive: "{submodule-recursive}"
374           submodule-timeout: "{submodule-timeout}"
375           submodule-disable: "{submodule-disable}"
376           choosing-strategy: gerrit
377
378     triggers:
379       - timed: "{obj:cron}"
380       - gerrit:
381           server-name: "{gerrit-server-name}"
382           trigger-on:
383             - comment-added-contains-event:
384                 comment-contains-value: '^Patch Set\s+\d+:\s+stage-release\s*$'
385           projects:
386             - project-compare-type: "ANT"
387               project-pattern: "{project}"
388               branches:
389                 - branch-compare-type: "ANT"
390                   branch-pattern: "**/{branch}"
391
392 - job-template:
393     name: "{project-name}-cmake-stage-{stream}"
394     id: github-cmake-stage
395     concurrent: true
396     <<: *lf_cmake_common
397     <<: *lf_cmake_stage
398
399     properties:
400       - lf-infra-properties:
401           build-days-to-keep: "{build-days-to-keep}"
402       - github:
403           url: "{github-url}/{github-org}/{project}"
404
405     scm:
406       - lf-infra-github-scm:
407           url: "{git-clone-url}{github-org}/{project}"
408           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
409           branch: "$sha1"
410           submodule-recursive: "{submodule-recursive}"
411           submodule-timeout: "{submodule-timeout}"
412           submodule-disable: "{submodule-disable}"
413           choosing-strategy: default
414           jenkins-ssh-credential: "{jenkins-ssh-credential}"
415
416     triggers:
417       - timed: "{obj:cron}"
418       - github-pull-request:
419           trigger-phrase: "^(stage-release)$"
420           only-trigger-phrase: true
421           status-context: "CMake Stage"
422           permit-all: true
423           github-hooks: true
424           white-list-target-branches:
425             - "{branch}"
426
427 ################
428 # CMAKE VERIFY #
429 ################
430
431 - lf_cmake_verify: &lf_cmake_verify
432     name: lf-cmake-verify
433
434     ######################
435     # Default parameters #
436     ######################
437
438     branch: master
439     build-days-to-keep: 7
440     build-dir: "$WORKSPACE/target"
441     build-timeout: 15
442     cmake-opts: ""
443     disable-job: false
444     git-url: "$GIT_URL/$PROJECT"
445     github-url: "https://github.com"
446     install-prefix: "$BUILD_DIR/output"
447     make-opts: ""
448     pre-build: ""
449     stream: master
450     submodule-recursive: true
451     submodule-timeout: 10
452     submodule-disable: false
453
454     gerrit_verify_triggers:
455       - patchset-created-event:
456           exclude-drafts: true
457           exclude-trivial-rebase: false
458           exclude-no-code-change: false
459       - draft-published-event
460       - comment-added-contains-event:
461           comment-contains-value: '^Patch Set\s+\d+:\s+(recheck|reverify)\s*$'
462
463     gerrit_trigger_file_paths:
464       - compare-type: REG_EXP
465         pattern: ".*"
466
467     # github_included_regions MUST match gerrit_trigger_file_paths
468     github_included_regions:
469       - ".*"
470
471     builders:
472       - shell: "{pre-build}"
473       - shell: !include-raw-escape: ../shell/cmake-build.sh
474
475 - job-template:
476     name: "{project-name}-cmake-verify-{stream}"
477     id: gerrit-cmake-verify
478     concurrent: true
479     <<: *lf_cmake_common
480     <<: *lf_cmake_verify
481
482     scm:
483       - lf-infra-gerrit-scm:
484           branch: "$GERRIT_BRANCH"
485           jenkins-ssh-credential: "{jenkins-ssh-credential}"
486           git-url: "{git-url}"
487           refspec: "$GERRIT_REFSPEC"
488           submodule-recursive: "{submodule-recursive}"
489           submodule-timeout: "{submodule-timeout}"
490           submodule-disable: "{submodule-disable}"
491           choosing-strategy: gerrit
492
493     triggers:
494       - gerrit:
495           server-name: "{gerrit-server-name}"
496           trigger-on: "{obj:gerrit_verify_triggers}"
497           projects:
498             - project-compare-type: "ANT"
499               project-pattern: "{project}"
500               branches:
501                 - branch-compare-type: "ANT"
502                   branch-pattern: "**/{branch}"
503               file-paths: "{obj:gerrit_trigger_file_paths}"
504
505 - job-template:
506     name: "{project-name}-cmake-verify-{stream}"
507     id: github-cmake-verify
508     concurrent: true
509     <<: *lf_cmake_common
510     <<: *lf_cmake_verify
511
512     properties:
513       - lf-infra-properties:
514           build-days-to-keep: "{build-days-to-keep}"
515       - github:
516           url: "{github-url}/{github-org}/{project}"
517
518     scm:
519       - lf-infra-github-scm:
520           url: "{git-clone-url}{github-org}/{project}"
521           refspec: "+refs/pull/*:refs/remotes/origin/pr/*"
522           branch: "$sha1"
523           submodule-recursive: "{submodule-recursive}"
524           submodule-timeout: "{submodule-timeout}"
525           submodule-disable: "{submodule-disable}"
526           choosing-strategy: default
527           jenkins-ssh-credential: "{jenkins-ssh-credential}"
528
529     triggers:
530       - github-pull-request:
531           trigger-phrase: "^(recheck|reverify)$"
532           only-trigger-phrase: false
533           status-context: "CMake Verify"
534           permit-all: true
535           github-hooks: true
536           included-regions: "{obj:github_included_regions}"
537           white-list-target-branches:
538             - "{branch}"